Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prometheus - Convert cpu_user_seconds to CPU Usage %?

I'm monitoring docker containers via Prometheus.io. My problem is that I'm just getting cpu_user_seconds_total or cpu_system_seconds_total.

How to convert this ever-increasing value to a CPU percentage?

Currently I'm querying:

rate(container_cpu_user_seconds_total[30s]) 

But I don't think that it is quite correct (comparing to top).

How to convert cpu_user_seconds_total to CPU percentage? (Like in top)

like image 688
M156 Avatar asked Jan 21 '16 12:01

M156


People also ask

How do you convert Cpu_user_seconds to CPU usage in percentage?

1 second every second on 1 core will be 100%. 3 cores at 50% will be 1.5 seconds every second, etc...

What is CPU seconds total?

With every PythonAnywhere account, you get a number of CPU-seconds included each day. This applies to all code run through our in-browser consoles, and in your scheduled tasks. It does not currently apply to your web apps. A CPU-second is one second of full-power usage on a server-grade CPU.


1 Answers

Rate returns a per second value, so multiplying by 100 will give a percentage:

rate(container_cpu_user_seconds_total[30s]) * 100

like image 124
brian-brazil Avatar answered Sep 21 '22 23:09

brian-brazil