add support for custom annotations

This commit is contained in:
jeltz 2023-11-01 23:32:03 +01:00
parent e1893769da
commit b5e9e1afb6
Signed by: jeltz
GPG key ID: 800882B66C0C3326

11
bot.py
View file

@ -30,6 +30,10 @@ TEMPLATE_TEXT = (
"{{ labels.alertname }} {{ labels.instance }}"
"{% if annotations.summary %}"
"\n{{ annotations.summary }}"
"{% else %}"
"{% for key, value in annotations.items() %}"
"\n{{ key }} : {{ value }}"
"{% endfor %}"
"{% endif %}"
)
@ -46,6 +50,13 @@ TEMPLATE_HTML = (
"{% if annotations.summary %}"
"<br/>"
"<blockquote>{{ annotations.summary }}</blockquote>"
"{% else %}"
"<br/>"
"<ul>"
"{% for key, value in annotations.items() %}"
"<li><b>{{ key | capitalize }} :</b> {{ value }}</li>"
"{% endfor %}"
"</ul>"
"{% endif %}"
)