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`