Container CPU usage average for 24h

558 views
Skip to first unread message

Yaron B

unread,
Aug 5, 2021, 11:27:49 AM8/5/21
to Prometheus Users
Hi,

I know that we can run rate(container_cpu_usage_seconds_total[5m]) to get the cpu usage of a container.

I would like to get the average of this usage over the last day.
however, when trying to add avg_over_time around it, I am getting  
parse error: ranges only allowed for vector selectors

How can I achieve what I need?

thanks!

Brian Candler

unread,
Aug 5, 2021, 1:15:33 PM8/5/21
to Prometheus Users
Trivially, rate(container_cpu_usage_seconds_total[24h]) will give you the average rate over the preceding 24 hours.

Of course, if you graph this, then it will vary up and down as the 24 hour window is sliding - so you only look at the value at midnight each day.  If necessary you can make a recording rule that does this for you.

Yaron B

unread,
Aug 12, 2021, 12:07:18 PM8/12/21
to Prometheus Users
thanks Brian!

ב-יום חמישי, 5 באוגוסט 2021 בשעה 20:15:33 UTC+3, Brian Candler כתב/ה:
Reply all
Reply to author
Forward
0 new messages