System:
- Grafana 9.2.0
- runs on Ubuntu 20.04
Question:
I am new to notification templating. I would like to setup a notification template that sends a summary notification (see code below for my current state of the template). I added this template under Text Body in the settings of the contact point.
The problem that I am facing is that I get a notification for each alert (which then read “1 firing:” and the Name, Summary, and Annotations). But instead I want a summary notification with all alerts that are firing.
How do I configure this?
Here is the code of my notification template (very much work in progress):
{{ if gt (len .Alerts.Firing) 0 }}
{{ len .Alerts.Firing }} firing:
{{ range .Alerts.Firing -}}
*Name*: {{ .Labels.alertname }}
*Summary*: {{ .Annotations.summary }}
{{ if gt (len .Annotations) 0 -}}
*Annotations*:
{{ range .Annotations.SortedPairs -}}
- {{ .Name }}: {{ .Value }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
{{ len .Alerts.Resolved }} resolved:
{{ range .Alerts.Resolved }}
{{ .Annotations.summary }}
{{ end }}
{{ end }}