Currently, I use external alertmanager to send email notifications. When alert is send, a mail arrive and in labels section are some additional things that were added by grafana, e.g.:
Labels
alertname = Out of disk space on VM
__ alert_rule_namespace_uid __ = Yj9eVzC7z
__ alert_rule_uid __ = 0k3Cgijnz
instance = 1.2.3.4:9182
job = Windows Nodes
name = Windows Share
volume = E:
To display this section in email, I use following statement: {{ range .Alerts.Firing }}{{ range .Labels.SortedPairs }}{{ .Name }} = {{ .Value }}{{ end }}{{ end}}
Is it possible to ommit somehow these key that were added by grafana (alert_rule_namespace_uid, alert_rule_uid) ? I saw Notification template reference (KV methods) contains something like Remove option, but I’m not sure how should look like the go templating code.
I’ve tried to create my own silenceurl, but if link contain these two keys, nothing is shown on grafana side (I must to delete them directly on web so affected alert instance will be shown).
Hi, I have the same question and it is related to the usage of the Remove method for the SortedPairs.
We can loop over sorted pairs and display them all like this:
{{ range .Labels.SortedPairs }}{{ .Name }}: {{ .Value }}{{ end }}
This shows all labels however. Let’s say I want a specific set of labels. According to the docs we can use the Remove method to remove certain keys from the SortedPairs. It requires a list as input. But how does one use this method inside the Grafana templating language?