added @here for alerts in rocket chat

This commit is contained in:
nd 2020-12-14 20:31:30 +01:00
parent ae12f28eb4
commit 14503ce330
No known key found for this signature in database
GPG key ID: 21B5CD4DEE3670E9

View file

@ -25,7 +25,7 @@ def postAlertmanager(chatName):
try:
content = json.loads(request.get_data())
for alert in content['alerts']:
message = "Status: "+alert['status']+"\n"
message = "@here\nStatus: "+alert['status']+"\n"
if 'name' in alert['labels']:
message += "Instance: "+alert['labels'].get('instance', 'unknown')+"("+alert['labels']['name']+")\n"
else:
@ -47,7 +47,7 @@ def postAlertmanager(chatName):
labels = ""
for l in alert['labels']:
labels += l + " : "+alert['labels'][l] + "\n"
message += labels + "```"
message += labels + "```\n"
if api.chat_post_message(message, channel=chatName, alias='Alertmanager').ok:
return "Alert OK", 200
else: