From 54a36221ba45a303e7b0e533d255a163c55047e4 Mon Sep 17 00:00:00 2001 From: Tom Herbers Date: Mon, 3 Jan 2022 15:13:55 +0100 Subject: [PATCH] config.sample.yaml: alertmanager: update example (text|html)_template Signed-off-by: Tom Herbers --- config.sample.yaml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/config.sample.yaml b/config.sample.yaml index e48c2ea..4857b68 100644 --- a/config.sample.yaml +++ b/config.sample.yaml @@ -163,6 +163,31 @@ services: # Each room will get the notification with the alert rendered with the given template rooms: "!someroomid:domain.tld": - text_template: "{{range .Alerts -}} [{{ .Status }}] {{index .Labels \"alertname\" }}: {{index .Annotations \"description\"}} {{ end -}}" - html_template: "{{range .Alerts -}} {{ $severity := index .Labels \"severity\" }} {{ if eq .Status \"firing\" }} {{ if eq $severity \"critical\"}} [FIRING - CRITICAL] {{ else if eq $severity \"warning\"}} [FIRING - WARNING] {{ else }} [FIRING - {{ $severity }}] {{ end }} {{ else }} [RESOLVED] {{ end }} {{ index .Labels \"alertname\"}} : {{ index .Annotations \"description\"}} source
{{end -}}" + text_template: > + {{range .Alerts -}} + {{- $severity := index .Labels "severity" -}} + {{- if eq .Status "firing" -}} + {{- if eq $severity "critical" -}} [CRITICAL] + {{- else if eq $severity "warning" -}} [WARNING] + {{- else if eq $severity "info" -}} [INFO] + {{- else -}} [{{ if $severity }}{{ $severity }}{{ else }}FIRING{{ end }}] + {{- end -}} + {{- else -}} [RESOLVED] + {{- end }} {{ index .Labels "alertname" -}} + {{- if index .Annotations "description" -}}: {{ index .Annotations "description" -}}{{- end }} + {{ end -}} + html_template: > + {{range .Alerts -}} + {{- $severity := index .Labels "severity" -}} + {{- if eq .Status "firing" -}} + {{- if eq $severity "critical" -}} [CRITICAL] + {{- else if eq $severity "warning" -}} [WARNING] + {{- else if eq $severity "info" -}} [INFO] + {{- else -}} [{{ if $severity }}{{ $severity }}{{ else }}FIRING{{ end }}] + {{- end -}} + {{- else -}} [RESOLVED] + {{- end }} {{ index .Labels "alertname" -}} + {{- if index .Annotations "description" -}}: {{ index .Annotations "description" -}}{{- end -}} + {{- if .GeneratorURL }} (source)
{{- end }} + {{ end -}} msg_type: "m.text" # Must be either `m.text` or `m.notice`