From 26460a0dcebbe214297dbb1a24c63de3f901f072 Mon Sep 17 00:00:00 2001 From: Paige Patton <64206430+paigerube14@users.noreply.github.com> Date: Thu, 5 Sep 2024 16:05:19 -0400 Subject: [PATCH] Adding elastic set to none (#691) * adding elastic set to none rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED Signed-off-by: Auto User * too many ls rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED --------- Signed-off-by: Auto User Co-authored-by: Auto User --- kraken/prometheus/client.py | 16 ++++++++-------- run_kraken.py | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/kraken/prometheus/client.py b/kraken/prometheus/client.py index 5a50c48d..e3466fdd 100644 --- a/kraken/prometheus/client.py +++ b/kraken/prometheus/client.py @@ -22,7 +22,7 @@ def alerts(prom_cli: KrknPrometheus, start_time, end_time, alert_profile, - elastic_colllect_alerts, + elastic_collect_alerts, elastic_alerts_index ): @@ -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") @@ -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]] = [] @@ -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") diff --git a/run_kraken.py b/run_kraken.py index 376928c1..5954836f 100644 --- a/run_kraken.py +++ b/run_kraken.py @@ -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)