How to monitor cpu utilization rate.
Can combine the cpu_usage data and some queries to calculate the rate?
@fabxc
Sorry I fogot to describe the problems..
I use cadvisor+prometheus+prom to monitor the containers in several vm..
Every things works well.But finally find the cpu utilization is cpu_usage_time
And can't read directly form the dashboard.
I want to show each container utilization rate but don't know how to write the query.
Could you give me some help?
Thanks a lot
Suppose you have that cadvisor metric container_cpu_usage_seconds_total with the container id and the cpu as a label.
The metric is a counter just showing you the total number of used seconds. You want a calculate a rate to see what's actually happening: rate(container_cpu_usage_seconds_total[1m]).
To get a more general overview you'll want to sum away the cpu label and normalize by the number of CPUs you have. A full query could look like this:
sum by (id, instance)(rate(container_cpu_usage_seconds_total[1m]))
/
count by (id, instance)(container_cpu_usage_seconds_total)
@fabxc
count by (id, instance)(container_cpu_usage_seconds_total)
May get the cpu number
And
sum by (id, instance)(rate(container_cpu_usage_seconds_total[1m]))
May get the cpu rate increase during 1 min.
But only compare the container itself not the cpu total resource?
Container_Used/CPU_Total_Used/Duration may get the result。
First ,the duration is 10s.
Second , Container_Used
sum by(id,instance)(delta(container_cpu_usage_seconds_total{name!=""}[10s]))
and how the cpu total time calculate?
Did the cadvisor metrics data privide ?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Suppose you have that cadvisor metric
container_cpu_usage_seconds_totalwith the container id and the cpu as a label.The metric is a counter just showing you the total number of used seconds. You want a calculate a rate to see what's actually happening:
rate(container_cpu_usage_seconds_total[1m]).To get a more general overview you'll want to sum away the cpu label and normalize by the number of CPUs you have. A full query could look like this: