Skip to content

Commit 5adf0d7

Browse files
committed
fix: summary heter nå description
Også lagt til feilhåndtering hvis nøkkel ikke finnes.
1 parent 1d9898c commit 5adf0d7

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

main.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,24 @@ def transform_text(text):
2020

2121

2222
def format_message(alert):
23+
status = alert['status'].upper()
24+
alert = alert['labels']['alertname']
25+
clusterID = alert['labels']['tenant_cluster_id']
26+
description = ''
27+
if 'description' in alert['annotations']:
28+
description = alert['annotations']['description']
29+
elif 'summery' in alert['annotations']:
30+
description = alert['annotations']['summery']
31+
elif 'action' in alert['annotations']:
32+
description = alert['annotations']['action']
33+
else:
34+
description = 'No description provided'
35+
2336
return '[{}] {} in {}%0a{}'.format(
24-
alert['status'].upper(),
25-
alert['labels']['alertname'],
26-
alert['labels']['tenant_cluster_id'],
27-
alert['annotations']['summary'])
37+
status,
38+
alert,
39+
clusterID,
40+
description)
2841

2942

3043
def send_sms(message, recipients):

0 commit comments

Comments
 (0)