Hi Brian,
Thanks for you inputs. Could you please help me where to add in and what to
modify in the below line of code to get the email subject with the keyword
"DOWN" for firing alerts and "UP" for resolved alerts.
{{ define "__subject" }}[{{ .Status | toUpper }}{{ if eq .Status "firing"
}}:{{ .Alerts.Firing | len }}{{ end }}] {{ .GroupLabels.SortedPairs.Values
| join " " }} {{ if gt (len .CommonLabels) (len .GroupLabels) }}({{ with
.CommonLabels.Remove .GroupLabels.Names }}{{ .Values | join " " }}{{ end
}}){{ end }}{{ end }}
Best Regards,
Suman
On Thursday, November 18, 2021 at 5:24:53 PM UTC+5:30 Brian Candler wrote:
> This is already done for you. With the default templates, the subject
> line has a prefix like [FIRING:2] or [RESOLVED].
>
> However if your alerts are being grouped, and let's say one alert
> resolves, then you might then get an E-mail with subject [FIRING:1] which
> shows one alert still firing and one alert resolved. That is: a single
> E-mail may contain both "DOWN" and "UP" notifications.
>
> You can change the templates if you like. There is documentation here
> <https://prometheus.io/docs/alerting/latest/notifications/>. The default
> subject line is created here
> <https://github.com/prometheus/alertmanager/blob/main/template/default.tmpl#L4>
> and
> you can override this with your own template string.
>
> But to be honest, I've switched off all "resolved" notifications now.
> There's a good explanation why here:
>
> https://www.robustperception.io/running-into-burning-buildings-because-the-fire-alarm-stopped
>
> In short: the fact that an alert condition has ceased is not an excuse to
> your staff to say "oh that's OK, the problem has gone; I can ignore it
> now". There *was* a problem and it *still* needs to be investigated. You
> can use an alert to open a ticket, but you should close the ticket manually.
>
> This document is also *very* well worth reading:
>
> https://docs.google.com/document/d/199PqyG3UsyXlwieHaqbGiWVa8eMWi8zzAn0YfcApr8Q/edit
>
> On Thursday, 18 November 2021 at 08:54:08 UTC [email protected] wrote:
>
>> Hi Team,
>>
>> I want to set the subject line in alertmanager based on send_resolved
>> status. I mean before resolving the alert subject line should be "DOWN" and
>> after resolving the alert subject line should be set to "UP".
>>
>> Could someone please guide me how to achieve this or provide me syntax
>> please?
>>
>> Best Regards,
>> Sriman
>>
>
--
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/002fe78f-bc93-403c-a710-1ab4c7ef9f46n%40googlegroups.com.