Filter on range query

18 views
Skip to first unread message

Johny

unread,
Aug 12, 2020, 12:12:48 PM8/12/20
to Prometheus Users
I have an alert condition based on count of metric value > 0 in last 10 min below a certain threshold.
count_over_time((mymetric{..} > 0)[10m:1m]) > x

Problem with this query is it evaluates each min in last 10 min and returns total of 5 even if there was a single data point in db — because of 5 min staleness in Prometheus. I want it to return 1.

Is there a way to filter a metric value in range query without using resolution? Or alternative way to formulate this alert?

Julien Pivotto

unread,
Aug 12, 2020, 12:20:32 PM8/12/20
to Johny, Prometheus Users
On 12 Aug 09:12, Johny wrote:

> I have an alert condition based on count of metric value > 0 in last 10 min below a certain threshold.
> count_over_time((mymetric{..} > 0)[10m:1m]) > x
>
> Problem with this query is it evaluates each min in last 10 min and returns total of 5 even if there was a single data point in db — because of 5 min staleness in Prometheus. I want it to return 1.

If you make sure that the :1m is your scrape interval staleness should
not be an issue.

>
> Is there a way to filter a metric value in range query without using resolution? Or alternative way to formulate this alert?
>
> --
> 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/6fe0b62b-7aa4-4a43-87ba-030a7bd2e2c1o%40googlegroups.com.


--
Julien Pivotto
@roidelapluie

Johny

unread,
Aug 12, 2020, 12:39:09 PM8/12/20
to Prometheus Users
In this case, I am doing a remote read.
Reply all
Reply to author
Forward
0 new messages