How to select time series data with "average value" <= threshold

23 views
Skip to first unread message

chuanjia xing

unread,
Apr 2, 2021, 7:34:21 PM4/2/21
to Prometheus Users
Hi there,
     I think my question is pretty common but looks like I can't find the answer to it. 
     The problem I am trying to solve is: Let's say I have 100 metrics data for cpuutilization for my instance. Each one is a time series for 1 day with granularity of 1 min. So each one has 1,440 data point. 
       Now I want to select the instances which has an "average cpu utilization" <= 10% for one day. How should I do this, basically how should I calculate the "average cpu utilization" for one time series? 
        One way I am thinking to do is, for each time series, I find the p90 data point and check if it is <= 10%. If it is, then I'll say that this instance data is with "average cpu utilization" <= 10% and select it. But looks like there's no function in Prometheus for me to find the p90 for a time series, or I just didn't find the right function for it.
         So, is above the right way to select? If yes, how can I find the p90 for a time series? If not, then how should I solve this problem?

Thanks,

Ben Kochie

unread,
Apr 3, 2021, 4:00:51 AM4/3/21
to chuanjia xing, Prometheus Users
You want to use one of the "over time" functions.

avg_over_time(cpu_utilization[1d]) < 0.10

quantile_over_time(0.9 cpu_utilization[1d]) < 0.10

--
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/89dfc6ac-2c05-4fab-8c04-eb68e32af214n%40googlegroups.com.

chuanjia xing

unread,
Apr 5, 2021, 7:23:53 PM4/5/21
to Prometheus Users
Thanks for your reply! I tried to use avg_over_time and quantile_over_time, these 2 functions will still return a time series data based on the cpu_utilization data. So if I apply "< 0.10" on it, it will still return the data points which are < 0.1. 
This 2 functions are helpful, but still I didn't get the result I need. For example, I apply these 2 functions for the cpu utilization data on 4/1/2021, I still get a time series for it. How can I determine if the "cpu utilization on 4/1/2021 is above or below 20%"? 

Reply all
Reply to author
Forward
0 new messages