From 846db899502ef62dd5d517d06e85636cce2ccfd7 Mon Sep 17 00:00:00 2001 From: psy Date: Sun, 3 Jan 2021 22:36:52 +0100 Subject: [PATCH] restructure template --- templates/rocketchat-bot.py.j2 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/templates/rocketchat-bot.py.j2 b/templates/rocketchat-bot.py.j2 index 1e7bb0d..cd2353b 100755 --- a/templates/rocketchat-bot.py.j2 +++ b/templates/rocketchat-bot.py.j2 @@ -27,10 +27,15 @@ def postAlertmanager(chatName): for alert in content['alerts']: message = "" if alert['status'] == "firing": - message += ":warning: @here\n" + message += ":warning: " else: - message += ":white_check_mark:\n" - message += "Status: **"+alert['status']+"**\n" + message += ":white_check_mark: " + if 'description' in alert['annotations']: + message += alert['annotations']['description'] + message += " **"+alert['status']+"** " + if alert['status'] == "firing": + message += "@here" + message += "\n" if 'name' in alert['labels']: message += "Instance: "+alert['labels'].get('instance', 'unknown')+"("+alert['labels']['name']+")\n" else: @@ -39,8 +44,6 @@ def postAlertmanager(chatName): message += "Info: "+alert['annotations']['info']+"\n" if 'summary' in alert['annotations']: message += "Summary: "+alert['annotations']['summary']+"\n" - if 'description' in alert['annotations']: - message += "Description: "+alert['annotations']['description']+"\n" if alert['status'] == "resolved": correctDate = parser.parse(alert['endsAt']).strftime('%Y-%m-%d %H:%M:%S') message += "Resolved: "+correctDate+"\n"