How can I define a different email subject for first notification

46 views
Skip to first unread message

eyal trigerman

unread,
Mar 11, 2020, 9:45:57 AM3/11/20
to Prometheus Users
Hi,

I would like to configure a different template for email subject:
one template for the first notification for an alert
other template for repeating notifications for an alert

Thanks!

Christian Hoffmann

unread,
Mar 11, 2020, 5:01:54 PM3/11/20
to eyal trigerman, Prometheus Users
Hi,
I'm not sure if Alertmanager exposes this state for usage in the template.

You could probably heuristically derive this information from the
StartsAt value when compared with your repeat interval. However, I'm not
sure if the available functions are sufficient to do that. Maybe some
further research will shed some more light on this. :)

Kind regards,
Christian

eyal trigerman

unread,
Mar 12, 2020, 3:44:47 AM3/12/20
to Prometheus Users
Thanks!
Can I have an example for a condition based on StartsAt?

בתאריך יום רביעי, 11 במרץ 2020 בשעה 23:01:54 UTC+2, מאת Christian Hoffmann:

Christian Hoffmann

unread,
Mar 14, 2020, 8:01:14 AM3/14/20
to eyal trigerman, Prometheus Users
Hi,

On 3/12/20 8:44 AM, eyal trigerman wrote:
> Thanks!
> Can I have an example for a condition based on StartsAt?
I don't have a specific example, I guess you will have to play around a bit.
For this to work, you probably should have your grouping set up in a way
which sends exactly one alert per group.

Then, you can reference this one alert's StartTime (e.g.
Alerts.Firing()[0].StartsAt -- totally not sure about the exact syntax).
There are conditional comparisons available in the Go templating (e.g.
lt or gt).
What I currently don't know is where to get the value from comparison
from -- this should be the same datetype as the StartsAt field but would
have to be set to "4 hours earlier" (or something; according to your
repeat_interval). This is the part where I'm not sure if there is a way
at all.

Maybe you can play around with this for yourself and ask again if you
hit a specific showstopper. Maybe other people can also chime in.

https://prometheus.io/docs/alerting/notifications/#alert
https://golang.org/pkg/text/template/

Kind regards,
Christian
> --
> 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 prometheus-use...@googlegroups.com
> <mailto:prometheus-use...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/b60cb6d3-44a2-4065-8858-d10f21c009eb%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-users/b60cb6d3-44a2-4065-8858-d10f21c009eb%40googlegroups.com?utm_medium=email&utm_source=footer>.

Reply all
Reply to author
Forward
0 new messages