Update case formatting:
- remove env from subject
- remove hardcoded advice descriptions
Change-Id: I5636bc2a5f6636d4c663bb0041b7509891e9126d
Related-bug: PROD-24843 (PROD:24843)
diff --git a/sf_notifier/helpers.py b/sf_notifier/helpers.py
index de02814..d1a655b 100644
--- a/sf_notifier/helpers.py
+++ b/sf_notifier/helpers.py
@@ -17,17 +17,23 @@
RESOLVED_STATUSES = ('UP', 'OK', 'resolved')
-def _format_subject(alert, env):
- subject = '[{}]'.format(alert['labels'].get('environment', env))
-
+def _format_subject(alert):
+ subject = alert['annotations']['summary']
host = alert['labels'].get('host')
if host is not None:
- subject = '{}[{}]'.format(subject, host)
-
- return '{} {}'.format(subject, alert['annotations']['summary'])
+ return '[{}] {}'.format(host, subject)
+ return subject
-def alert_fields_and_action(alert, env):
+def _remove_advice(description):
+ return description.split(' Modify the')[0]
+
+
+def _format_description(alert):
+ return _remove_advice(alert['annotations']['description'])
+
+
+def alert_fields_and_action(alert):
fields = []
if alert['status'] in RESOLVED_STATUSES:
@@ -36,8 +42,8 @@
else:
action = 'create_case'
# Order of keys matters
- fields.append(_format_subject(alert, env))
- fields.append(alert['annotations']['description'])
+ fields.append(_format_subject(alert))
+ fields.append(_format_description(alert))
fields.append(alert['status'])
fields.append(alert['labels'])
return fields, action