If you would also expect an alert when it changes from 1 to 0, then changes 
<https://prometheus.io/docs/prometheus/latest/querying/functions/#changes>() 
may be what you're looking for.  It counts the number of changes for each 
series in a range vector.

changes(blah[5m]) > 0

(or "> bool 0" if you want a 0/1 value which is amenable to summing)

> But we want triggered in X past time.
...
> i.e. just return the most recent one that triggered in the past 5 minutes

I don't understand either of those requirements.

You can use grouping in alertmanager so that alerts for customerA, 
customerB and customerC are grouped into the same alert.

On Thursday, 9 September 2021 at 14:42:06 UTC+1 Dan S wrote:

> So we have a gauge metric that is just zero or one.  Starts at zero, goes 
> to one when event happens, rarely if ever goes back to zero.
>
> We want to alert after event change 0->1 happens, but have the alert stop 
> after X time, and not alert indefinitely.
>
> Basically this returns the data of what triggered:
>
> sum by (customer) (event_triggered) > 0
> {customer="A"} 1
> {customer="B"} 1
> {customer="C"} 1
>
> But we want triggered in X past time.  I realize rate doesn't work because 
> it's not a counter... but ideally would want something like this:
>
> sum by (customer) (rate(event_triggered[5m])) > 0
> {customer="A"} .003 
>
> i.e. just return the most recent one that triggered in the past 5 minutes 
> and have it stop alerting once it returns to base (which is now 1)
>
> Thanks
> Dan
>

-- 
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/99f375ab-1f98-49e1-94b3-795560b1ff27n%40googlegroups.com.

Reply via email to