Add possiblity to set CLUSTER_ID via env var
- mitigate missing alert_relabel_configs in Cortex
- if missing in the alert labels it will be added
Change-Id: I89bcc0672aa663178d02e69bdc941c1fcc63db80
Related-PROD: PRODX-24796
diff --git a/sf_notifier/helpers.py b/sf_notifier/helpers.py
index 6965b70..4dc4048 100644
--- a/sf_notifier/helpers.py
+++ b/sf_notifier/helpers.py
@@ -53,9 +53,13 @@
return '{}\n\n{}:\n{}'.format(description_old, msg, prometheus_url)
-def alert_fields_and_action(alert, add_links=False):
+def alert_fields_and_action(alert, add_links=False, cluster_id=None):
fields = []
+ if cluster_id is not None:
+ if alert['labels'].get('cluster_id') is None:
+ alert['labels']['cluster_id'] = cluster_id
+
if alert['status'] in RESOLVED_STATUSES:
action = 'close_case'
fields.append(alert['labels'])