On Monday, 4 October 2021 at 19:25:01 UTC+1 Dan S wrote:
> Brian, even better - great.
>
> Now that you mentioned how count() returns no labels - it relates to
> another alert rule I was trying to implement.
> If I wanted to alert anytime a counter is incremented (and have it self
> resolve after x time), this seems to do it:
>
> *count(exception_total) - count(exception_total offset 1h) *
> {} 0
>
At first glance, that expression will always alert, so you'll want to wrap
it in (....) > 0
But are you sure you want "count" there? It implies that you will get
multiple *timeseries* for exception_total. If it's a single metric, then
you want
(metric_total - metric_total offset 1h) > 0
> above returns a zero value when it has been incremented but no labels or
> useful results otherwise, but this other query I happened upon returns
> labels and I don't understand why
>
> *exception_total unless exception_total offset 1h*
>
> exception_total{pod="x"} 1
> exception_total{pod="y"} 1
> exception_total{pod="z"} 1
>
>
Compare these two expressions separately:
(A) exception_total
(B) exception_total offset 1h
You'll only get a result if (A) has a timeseries but (B) has no
corresponding timeseries (meaning with exactly the same labels).
--
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/8be84911-6b2f-4fdc-a7e7-007ea54de5dan%40googlegroups.com.