From 8df5f497d8c05e37b4d0dccde4df8fe96a499c86 Mon Sep 17 00:00:00 2001 From: nd Date: Fri, 20 Nov 2020 23:38:05 +0100 Subject: [PATCH] ensure no error is generated if we try to send an alert without an instance label via telegram --- templates/telegram-bot.py.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/telegram-bot.py.j2 b/templates/telegram-bot.py.j2 index ffc4d8d..db5a997 100755 --- a/templates/telegram-bot.py.j2 +++ b/templates/telegram-bot.py.j2 @@ -22,9 +22,9 @@ def postAlertmanager(chatID): for alert in content['alerts']: message = "Status: "+alert['status']+"\n" if 'name' in alert['labels']: - message += "Instance: "+alert['labels']['instance']+"("+alert['labels']['name']+")\n" + message += "Instance: "+alert['labels'].get('instance', 'unknown')+"("+alert['labels']['name']+")\n" else: - message += "Instance: "+alert['labels']['instance']+"\n" + message += "Instance: "+alert['labels'].get('instance', 'unknown')+"\n" if 'info' in alert['annotations']: message += "Info: "+alert['annotations']['info']+"\n" if 'summary' in alert['annotations']: