From e138e65f9a2cd154a7ddecb04878023406c8f061 Mon Sep 17 00:00:00 2001 From: Samyak S Sarnayak Date: Mon, 4 Jul 2022 11:46:52 +0530 Subject: [PATCH 1/5] fix(alerts-dashboard): consider only alert triggers with anomaly setup This was causing an issue where if anomaly was manually disabled by setting `anomaly_params` to NULL, getting the time series frequency would fail. This was not considered since disabling anomaly was not a feature that was implemented. --- chaos_genius/controllers/digest_controller.py | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/chaos_genius/controllers/digest_controller.py b/chaos_genius/controllers/digest_controller.py index 63fecf087..5226932ae 100644 --- a/chaos_genius/controllers/digest_controller.py +++ b/chaos_genius/controllers/digest_controller.py @@ -243,22 +243,27 @@ def extract_anomaly_points_from_triggered_alerts( "Error in extracting an anomaly point from triggered alert", exc_info=e, ) - anomaly_points.extend( - AnomalyPointFormatted.from_points( - trig_alert_points, - time_series_frequency=getattr( - kpi_cache.get(triggered_alert.kpi_id), "anomaly_params", {} - ).get("frequency"), - kpi_id=triggered_alert.kpi_id, - kpi_name=triggered_alert.kpi_name, - alert_id=triggered_alert.alert_conf_id, - alert_name=triggered_alert.alert_name, - alert_channel=triggered_alert.alert_channel, - alert_channel_conf=triggered_alert.alert_channel_conf, - include_subdims=triggered_alert.include_subdims, - ) + + anomaly_params = getattr( + kpi_cache.get(triggered_alert.kpi_id), "anomaly_params", {} ) + # consider only KPIs which have anomaly enabled + if anomaly_params is not None: + anomaly_points.extend( + AnomalyPointFormatted.from_points( + trig_alert_points, + time_series_frequency=anomaly_params.get("frequency"), + kpi_id=triggered_alert.kpi_id, + kpi_name=triggered_alert.kpi_name, + alert_id=triggered_alert.alert_conf_id, + alert_name=triggered_alert.alert_name, + alert_channel=triggered_alert.alert_channel, + alert_channel_conf=triggered_alert.alert_channel_conf, + include_subdims=triggered_alert.include_subdims, + ) + ) + return anomaly_points From 792efab2f3cbaf2de91176be8579a3266eddae06 Mon Sep 17 00:00:00 2001 From: chartisdev Date: Wed, 6 Jul 2022 10:13:54 +0530 Subject: [PATCH 2/5] added css class to seperate alert configuration CSS --- frontend/src/components/KpiAlertConfigurationForm/index.jsx | 4 +++- .../KpiAlertConfigurationForm/kpialertconfigurationform.scss | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/KpiAlertConfigurationForm/index.jsx b/frontend/src/components/KpiAlertConfigurationForm/index.jsx index 4f54892fc..b51e56595 100644 --- a/frontend/src/components/KpiAlertConfigurationForm/index.jsx +++ b/frontend/src/components/KpiAlertConfigurationForm/index.jsx @@ -627,7 +627,9 @@ const KpiAlertConfigurationForm = ({ )} -
+
Date: Wed, 6 Jul 2022 19:13:33 +0530 Subject: [PATCH 3/5] style(alerts): format slack.py with black --- chaos_genius/alerts/slack.py | 82 ++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 46 deletions(-) diff --git a/chaos_genius/alerts/slack.py b/chaos_genius/alerts/slack.py index 28fe0cdd2..2dab59029 100644 --- a/chaos_genius/alerts/slack.py +++ b/chaos_genius/alerts/slack.py @@ -109,40 +109,40 @@ def alert_digest_slack_formatted(data: "AlertsReportData") -> str: raise Exception("Slack not configured properly.") blocks = [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": f"Daily Alerts Report ({data.report_date_formatted()})", - "emoji": True, - }, - }, - { - "type": "divider", - }, - { - "type": "header", - "text": { - "type": "plain_text", - "text": "Top Anomalies", - "emoji": True, - }, + { + "type": "header", + "text": { + "type": "plain_text", + "text": f"Daily Alerts Report ({data.report_date_formatted()})", + "emoji": True, }, - *_display_anomalies_digest(data), - *_display_anomalies_digest(data, subdim=True), - { - "type": "actions", - "elements": [ - { - "type": "button", - "text": {"type": "plain_text", "text": "Alerts Dashboard"}, - "url": data.alert_dashboard_link(), - "action_id": "alert_dashboard", - "style": "primary", - } - ], + }, + { + "type": "divider", + }, + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Top Anomalies", + "emoji": True, }, - ] + }, + *_display_anomalies_digest(data), + *_display_anomalies_digest(data, subdim=True), + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": {"type": "plain_text", "text": "Alerts Dashboard"}, + "url": data.alert_dashboard_link(), + "action_id": "alert_dashboard", + "style": "primary", + } + ], + }, + ] response = client.send(blocks=blocks) @@ -157,10 +157,7 @@ def _display_anomalies_individual(anomaly_data, subdim: bool = False): sections: List[Dict[str, Any]] = [] section = { "type": "section", - "text": { - "type": "mrkdwn", - "text": "" - }, + "text": {"type": "mrkdwn", "text": ""}, } if not subdim: @@ -199,10 +196,7 @@ def _display_anomalies_digest(anomaly_data, subdim: bool = False): def _new_text_section() -> Dict[str, Any]: section = { "type": "section", - "text": { - "type": "mrkdwn", - "text": "" - }, + "text": {"type": "mrkdwn", "text": ""}, } sections.append(section) return section @@ -259,14 +253,10 @@ def subdim_name_link(point, value_only: bool = False): """Creates subdim name with link to respective subdim anomaly page.""" if value_only: subdim_link = ( - f"<{point.subdim_link()}" - + f"|{point.subdim_formatted_value_only()}>" + f"<{point.subdim_link()}" + f"|{point.subdim_formatted_value_only()}>" ) else: - subdim_link = ( - f"<{point.subdim_link()}" - + f"|{point.subdim_formatted()}>" - ) + subdim_link = f"<{point.subdim_link()}" + f"|{point.subdim_formatted()}>" return subdim_link From 3f916827d3fea6b9628543004451c6f966658a5b Mon Sep 17 00:00:00 2001 From: Samyak S Sarnayak Date: Wed, 6 Jul 2022 19:16:19 +0530 Subject: [PATCH 4/5] fix(alerts): wrong formats when subdims were not present "Sub-dimensional anomalies" heading was present even when there weren't any subdim anomalies in individual alerts. "Reasons for change" text was present even when there weren't any relevant subdims. --- chaos_genius/alerts/email_templates/common.html | 2 +- chaos_genius/alerts/email_templates/email_alert.html | 2 +- chaos_genius/alerts/slack.py | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/chaos_genius/alerts/email_templates/common.html b/chaos_genius/alerts/email_templates/common.html index 27e8d5680..98402fc16 100644 --- a/chaos_genius/alerts/email_templates/common.html +++ b/chaos_genius/alerts/email_templates/common.html @@ -216,7 +216,7 @@ {%- endif %} {%- endif %}{% if point.relevant_subdims is not none -%} + -->{% if point.relevant_subdims -%}
  • Reasons for change: diff --git a/chaos_genius/alerts/email_templates/email_alert.html b/chaos_genius/alerts/email_templates/email_alert.html index 973dc0d84..dfd3f29a4 100644 --- a/chaos_genius/alerts/email_templates/email_alert.html +++ b/chaos_genius/alerts/email_templates/email_alert.html @@ -40,7 +40,7 @@

    Anomalies

{% endif %} -{% if data.include_subdims %} +{% if data.include_subdims and data.top_subdim_points %}

Sub-dimensional anomalies

    {% for point in data.top_subdim_points %} diff --git a/chaos_genius/alerts/slack.py b/chaos_genius/alerts/slack.py index 2dab59029..150a93f35 100644 --- a/chaos_genius/alerts/slack.py +++ b/chaos_genius/alerts/slack.py @@ -28,7 +28,6 @@ def anomaly_alert_slack( Returns an empty string if successful or the error as a string if not. """ - # TODO: Fix this implementation to use AlertsIndividualData client = get_webhook_client() response = client.send( blocks=[ @@ -169,7 +168,7 @@ def _display_anomalies_individual(anomaly_data, subdim: bool = False): section["text"]["text"] += point_formatted sections.append(section) else: - if anomaly_data.include_subdims: + if anomaly_data.include_subdims and anomaly_data.top_subdim_points: header_section = { "type": "header", "text": { @@ -321,7 +320,7 @@ def anomaly_point_formatting( + f" to {point.anomaly_time_only}" ) - if point.relevant_subdims is not None: + if point.relevant_subdims: out += "\n - Reasons for change: " for point in point.top_relevant_subdims() or []: out += f"{subdim_name_link(point, value_only=True)}, " From 06aee7281e1727ca29cd7d35ea301d105a95502b Mon Sep 17 00:00:00 2001 From: Samyak S Sarnayak Date: Fri, 8 Jul 2022 13:26:01 +0530 Subject: [PATCH 5/5] release: bump version to v0.9.1 --- chaos_genius/settings.py | 2 +- docker-compose.thirdparty.yml | 10 +++++----- docker-compose.yml | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/chaos_genius/settings.py b/chaos_genius/settings.py index 064e88577..b7e5e5b0a 100644 --- a/chaos_genius/settings.py +++ b/chaos_genius/settings.py @@ -149,7 +149,7 @@ def _make_bool(val: Union[str, bool]) -> bool: TASK_CHECKPOINT_LIMIT: int = int(os.getenv("TASK_CHECKPOINT_LIMIT", 1000)) """Number of last checkpoints to retrieve in Task Monitor""" -CHAOSGENIUS_VERSION_MAIN = os.getenv("CHAOSGENIUS_VERSION_MAIN", "0.9.0") +CHAOSGENIUS_VERSION_MAIN = os.getenv("CHAOSGENIUS_VERSION_MAIN", "0.9.1") """ChaosGenius version - semver part only""" CHAOSGENIUS_VERSION_POSTFIX = os.getenv("CHAOSGENIUS_VERSION_POSTFIX", "git") """ChaosGenius version - postfix to identify deployment""" diff --git a/docker-compose.thirdparty.yml b/docker-compose.thirdparty.yml index d265c49d5..a40d74dc8 100644 --- a/docker-compose.thirdparty.yml +++ b/docker-compose.thirdparty.yml @@ -38,7 +38,7 @@ services: chaosgenius-server: container_name: chaosgenius-server - image: chaosgenius/chaosgenius-server:0.9.0 + image: chaosgenius/chaosgenius-server:0.9.1 command: sh setup/run-backend-docker.sh restart: unless-stopped volumes: @@ -97,7 +97,7 @@ services: chaosgenius-webapp: container_name: chaosgenius-webapp - image: chaosgenius/chaosgenius-webapp:0.9.0 + image: chaosgenius/chaosgenius-webapp:0.9.1 command: > sh -c "npx react-inject-env set -d ./ && nginx -g 'daemon off;'" @@ -138,7 +138,7 @@ services: chaosgenius-scheduler: container_name: chaosgenius-scheduler - image: chaosgenius/chaosgenius-server:0.9.0 + image: chaosgenius/chaosgenius-server:0.9.1 command: celery -A run.celery beat --loglevel=DEBUG restart: unless-stopped environment: @@ -175,7 +175,7 @@ services: chaosgenius-worker-analytics: container_name: chaosgenius-worker-analytics - image: chaosgenius/chaosgenius-server:0.9.0 + image: chaosgenius/chaosgenius-server:0.9.1 command: celery -A run.celery worker --loglevel=INFO --concurrency=2 -P processes -Q anomaly-rca restart: unless-stopped environment: @@ -229,7 +229,7 @@ services: chaosgenius-worker-alerts: container_name: chaosgenius-worker-alerts - image: chaosgenius/chaosgenius-server:0.9.0 + image: chaosgenius/chaosgenius-server:0.9.1 command: celery -A run.celery worker --loglevel=INFO --concurrency=2 -P processes -Q alerts restart: unless-stopped environment: diff --git a/docker-compose.yml b/docker-compose.yml index ccb91b948..f93266fb3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ x-version: services: chaosgenius-server: container_name: chaosgenius-server - image: chaosgenius/chaosgenius-server:0.9.0 + image: chaosgenius/chaosgenius-server:0.9.1 command: sh setup/run-backend-docker.sh restart: unless-stopped volumes: @@ -70,7 +70,7 @@ services: chaosgenius-webapp: container_name: chaosgenius-webapp - image: chaosgenius/chaosgenius-webapp:0.9.0 + image: chaosgenius/chaosgenius-webapp:0.9.1 command: > sh -c "npx react-inject-env set -d ./ && nginx -g 'daemon off;'" @@ -109,7 +109,7 @@ services: chaosgenius-scheduler: container_name: chaosgenius-scheduler - image: chaosgenius/chaosgenius-server:0.9.0 + image: chaosgenius/chaosgenius-server:0.9.1 command: celery -A run.celery beat --loglevel=DEBUG restart: unless-stopped environment: @@ -146,7 +146,7 @@ services: chaosgenius-worker-analytics: container_name: chaosgenius-worker-analytics - image: chaosgenius/chaosgenius-server:0.9.0 + image: chaosgenius/chaosgenius-server:0.9.1 command: celery -A run.celery worker --loglevel=INFO --concurrency=2 -P processes -Q anomaly-rca restart: unless-stopped environment: @@ -200,7 +200,7 @@ services: chaosgenius-worker-alerts: container_name: chaosgenius-worker-alerts - image: chaosgenius/chaosgenius-server:0.9.0 + image: chaosgenius/chaosgenius-server:0.9.1 command: celery -A run.celery worker --loglevel=INFO --concurrency=2 -P processes -Q alerts restart: unless-stopped environment: