Format notifications in a more readable way
- Add the following template to
Alerting/Contact points/Notification Templateswith the namepayload_message
{{ define "payload_message" -}}
{{ range .Alerts -}}
[{{ .Status }} {{ if eq .Status "firing" }}🔥{{ else }}{{ if eq .Status "resolved" }}✅{{ end }}{{ end }}] {{ .Labels.alertname }}{{ if .Labels.instance }} ({{ .Labels.instance }}){{ end }}{{/*
Values:{{ if len .Values }}{{ $first := true }}{{ range $refID, $value := .Values -}}{{ if $first }}{{ $first = false }}{{ else }}{{ end }}
- {{ $refID }}: {{ $value }}
{{- end }}
{{ else }} [no value]
{{ end -}} */}}{{/*
Value:{{ if .Annotations.value }}
- {{ .Annotations.value }}{{ else }}
- [no `value` field provided]{{ end }} */}}
Labels:{{ range .Labels.SortedPairs -}}
{{ if and (ne .Name "alertname") (ne .Name "instance") }}
- {{ .Name }}: {{ .Value -}}
{{ end -}}
{{ end -}}
{{ if gt (len .Annotations) 0 }}
Details:{{ range .Annotations.SortedPairs -}}{{/*
{{ if (ne .Name "value") }}
- {{ .Name }}: {{ .Value }}
{{ else }}{{ end -}} */}}
- {{ .Name }}: {{ .Value }}
{{ end -}}
{{ else }}
{{ end }}
{{ end }}
{{ end }}
- For every Alert rule you have configured, add a custom annotation with the name
valueand a value similar to{{ humanize $values.A.Value }}