Skip to content

Commit

Permalink
Adding elastic set to none (krkn-chaos#691)
Browse files Browse the repository at this point in the history
* adding elastic set to none

rh-pre-commit.version: 2.2.0
rh-pre-commit.check-secrets: ENABLED

Signed-off-by: Auto User <[email protected]>

* too many ls

rh-pre-commit.version: 2.2.0
rh-pre-commit.check-secrets: ENABLED

---------

Signed-off-by: Auto User <[email protected]>
Co-authored-by: Auto User <[email protected]>
  • Loading branch information
paigerube14 and Auto User authored Sep 5, 2024
1 parent 7968c2a commit 26460a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 8 additions & 8 deletions kraken/prometheus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def alerts(prom_cli: KrknPrometheus,
start_time,
end_time,
alert_profile,
elastic_colllect_alerts,
elastic_collect_alerts,
elastic_alerts_index
):

Expand All @@ -45,12 +45,12 @@ def alerts(prom_cli: KrknPrometheus,
processed_alert = prom_cli.process_alert(alert,
datetime.datetime.fromtimestamp(start_time),
datetime.datetime.fromtimestamp(end_time))
if processed_alert[0] and processed_alert[1] and elastic_colllect_alerts:
if processed_alert[0] and processed_alert[1] and elastic and elastic_collect_alerts:
elastic_alert = ElasticAlert(run_uuid=run_uuid,
severity=alert["severity"],
alert=processed_alert[1],
created_at=datetime.datetime.fromtimestamp(processed_alert[0])
)
severity=alert["severity"],
alert=processed_alert[1],
created_at=datetime.datetime.fromtimestamp(processed_alert[0])
)
result = elastic.push_alert(elastic_alert, elastic_alerts_index)
if result == -1:
logging.error("failed to save alert on ElasticSearch")
Expand Down Expand Up @@ -119,7 +119,7 @@ def metrics(prom_cli: KrknPrometheus,
start_time,
end_time,
metrics_profile,
elastic_colllect_metrics,
elastic_collect_metrics,
elastic_metrics_index
) -> list[dict[str, list[(int, float)] | str]]:
metrics_list: list[dict[str, list[(int, float)] | str]] = []
Expand Down Expand Up @@ -154,7 +154,7 @@ def metrics(prom_cli: KrknPrometheus,
pass
metrics_list.append(metric)

if elastic_colllect_metrics:
if elastic_collect_metrics and elastic:
result = elastic.upload_metrics_to_elasticsearch(run_uuid=run_uuid, index=elastic_metrics_index, raw_data=metrics_list)
if result == -1:
logging.error("failed to save metrics on ElasticSearch")
Expand Down
2 changes: 2 additions & 0 deletions run_kraken.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ def main(cfg) -> int:
elastic_username,
elastic_password
)
else:
elastic_search = None
summary = ChaosRunAlertSummary()
if enable_metrics or enable_alerts or check_critical_alerts:
prometheus = KrknPrometheus(prometheus_url, prometheus_bearer_token)
Expand Down

0 comments on commit 26460a0

Please sign in to comment.