Prometheus alertmanger email format

132 views
Skip to first unread message

Prashant Singh

unread,
Jan 27, 2023, 4:19:13 AM1/27/23
to Prometheus Users
Dear ALl,

how can modfy alertmanager email format 
1. Subject 
2 Email body ( custom lable with values, start time )
3. Add  in email " Regrads - Automcation team in bottom of email alert.
4. Need reslove or ack email 



Thanks,
Prashant 

Brian Candler

unread,
Jan 27, 2023, 4:52:58 AM1/27/23
to Prometheus Users
See:
https://prometheus.io/docs/alerting/latest/notifications/

I believe this is the default template:

You specify the Subject template as an entry under "headers:".  If you don't define a subject header, then a default one is used, picked up from a shared template "__subject". See:

Whether or not to send the resolve email is set using the attribute "send_resolved: true/false": see

Simple example:

receivers:
- name: foo
  email_configs:
  - to: 'f...@example.com'
    send_resolved: true
    headers:
      subject: '{{ if eq .Status "firing" }}DOWN{{ else if eq .Status "resolved" }}UP{{end}}'

(Note that a single notification may contain a group of alerts, some firing and some resolved.  .Status set to "firing" if at least one of them is firing)

Prashant Singh

unread,
Jan 27, 2023, 11:55:31 PM1/27/23
to Prometheus Users

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) 28 contains something like Remove option, but I’m not sure how should look like the go templating code.



thanks,

prashant 

Brian Candler

unread,
Jan 28, 2023, 7:31:08 AM1/28/23
to Prometheus Users
Sorry, I don't understand what you mean by "key that were added by grafana".
Reply all
Reply to author
Forward
0 new messages