From c1e1501649898ac277d375f6d6b139449dce053e Mon Sep 17 00:00:00 2001 From: Jeltz Date: Thu, 2 Nov 2023 00:01:11 +0100 Subject: [PATCH] make instance label optional --- bot.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index ad33f11..066e928 100755 --- a/bot.py +++ b/bot.py @@ -27,8 +27,9 @@ TEMPLATE_TEXT = ( "{% elif labels.severity == 'warning' %}" "ATTENTION " "{% endif %}" - "{{ labels.alertname }} {{ labels.instance }}" - "{% if annotations.summary %}" + "{{ labels.alertname }}" + "{% if labels.instance is defined %} {{ labels.instance }}{% endif %}" + "{% if annotations.summary is defined %}" "\n{{ annotations.summary }}" "{% else %}" "{% for key, value in annotations.items() %}" @@ -45,9 +46,9 @@ TEMPLATE_HTML = ( "{% elif labels.severity == 'warning' %}" "ATTENTION " "{% endif %}" - "{{ labels.alertname }} " - "{{ labels.instance }}" - "{% if annotations.summary %}" + "{{ labels.alertname }}" + "{% if labels.instance is defined %} {{ labels.instance }}{% endif %}" + "{% if annotations.summary is defined %}" "
" "
{{ annotations.summary }}
" "{% else %}"