avg_over_time OVER min

33 views
Skip to first unread message

Albert Aleksandrov

unread,
Apr 30, 2020, 5:30:46 AM4/30/20
to Prometheus Users
Hi all!
Let me start with example so as to be clear. Please, look at the screenshot. 

Заявление.jpg


As you can see there are two metrics. One have value 0. Other have value 1. In this case we consider that all values at the certain time are equal to 0. Such a kind of logical AND (min(health_check)):

Заявление.jpg


The final aim is to get average value over time. I tried this query:

      avg_over_time(min(health_check)[7d])

But it fails with error message:

 "1:32: parse error: ranges only allowed for vector selectors"

Could you say please how to deal with this?

Brian Candler

unread,
Apr 30, 2020, 5:36:16 AM4/30/20
to Prometheus Users
You need a subquery if you want to convert a subexpression into a range vector for avg_over_time. e.g.

    avg_over_time( (min(health_check))[7d:5m] )

This example will evaluate the inner expression at 5m intervals over 7d, to make a range vector.

Albert Aleksandrov

unread,
Apr 30, 2020, 6:19:55 AM4/30/20
to Prometheus Users
Thanx for your support, Brian!

четверг, 30 апреля 2020 г., 12:36:16 UTC+3 пользователь Brian Candler написал:
Reply all
Reply to author
Forward
0 new messages