Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prometheus query #1273

Closed
mysterytree opened this Issue Dec 23, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@mysterytree
Copy link

mysterytree commented Dec 23, 2015

How to monitor cpu utilization rate.
Can combine the cpu_usage data and some queries to calculate the rate?
@fabxc

@mysterytree

This comment has been minimized.

Copy link
Author

mysterytree commented Dec 23, 2015

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

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Dec 23, 2015

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)
@mysterytree

This comment has been minimized.

Copy link
Author

mysterytree commented Dec 24, 2015

@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 ?

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 24, 2019

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.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.