Getting the epoch ms of triggered alert

262 views
Skip to first unread message

Dudi Cohen

unread,
Jul 27, 2022, 6:43:09 AM7/27/22
to Prometheus Users
Hi,

I want to include a link to a Grafana dashboard within a Prometheus alert rule.
The time of the alert should be added as a query parameter in the dashboard URL so that the link leads you to the time when the alert was triggered.


Alertmanager has a `StartsAt` function which gives the current time: https://prometheus.io/docs/alerting/latest/notifications/#alert

Is there a way to convert this time output to epoch ms so I can use it within the Grafana dashboard URL?

Thanks

David Leadbeater

unread,
Jul 27, 2022, 7:43:57 AM7/27/22
to Dudi Cohen, Prometheus Users
Hi,

It's not pretty but you can use: {{ .StartsAt.Unix }}000

There's various other alternatives in the comments on
https://github.com/prometheus/alertmanager/issues/1188

David
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/af28e96b-255c-41af-b05a-624caa18a897n%40googlegroups.com.

Dudi Cohen

unread,
Jul 27, 2022, 8:31:07 AM7/27/22
to Prometheus Users

That did the trick, thanks a lot!
Reply all
Reply to author
Forward
0 new messages