alertmanager icon indicating copy to clipboard operation
alertmanager copied to clipboard

Missing a way to use time.Since and pretty format duration in templates

Open freak12techno opened this issue 1 year ago • 3 comments

I want to be able to use a custom template to display the time the alert started to fire and how much time is it firing for, something like:

⌛ Firing since: 2024-02-12 18:15:38.457 +0000 UTC (for 3 hours 42 minutes 21 seconds).

We already have .StartsAt field for alert, but there's no template helper to 1) use time.Since(), and 2) pretty-format duration, so it would be lovely to have it here as well.

freak12techno avatar Feb 12 '24 19:02 freak12techno

(I can and likely will add it by myself, if there's no objection)

freak12techno avatar Feb 12 '24 19:02 freak12techno

No objection from me - this seems sensible.

gotjosh avatar Feb 13 '24 11:02 gotjosh

@gotjosh okay I made a PR, can you look into that or ask somebody to review it? (not sure what's the workflow here)

freak12techno avatar Feb 13 '24 19:02 freak12techno