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 
<https://prometheus.io/docs/alerting/latest/notifications/#kv-methods> contains 
something like Remove option, but I’m not sure how should look like the go 
templating code.


thanks,

prashant 
On Friday, January 27, 2023 at 3:22:58 PM UTC+5:30 Brian Candler wrote:
See:
https://prometheus.io/docs/alerting/latest/notifications/
https://prometheus.io/docs/alerting/latest/notification_examples/
https://prometheus.io/docs/alerting/latest/configuration/#email_config

I believe this is the default template:
https://github.com/prometheus/alertmanager/blob/v0.25.0/template/email.tmpl

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:
https://github.com/prometheus/alertmanager/blob/v0.25.0/template/default.tmpl#L4
https://github.com/prometheus/alertmanager/blob/v0.25.0/config/notifiers.go#L63-L64
https://github.com/prometheus/alertmanager/blob/v0.25.0/notify/email/email.go#L54-L56

Whether or not to send the resolve email is set using the attribute 
"send_resolved: true/false": see
https://prometheus.io/docs/alerting/latest/configuration/#email_config

Simple example:

receivers:
- name: foo
  email_configs:
  - to: '[email protected]'
    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)

On Friday, 27 January 2023 at 09:19:13 UTC [email protected] wrote:
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 

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/bcac8308-7e88-4182-be9f-88ce04962bedn%40googlegroups.com.

Reply via email to