Prometheus - Convert cpu_user_seconds to CPU Usage %?

M156 picture M156 · Jan 21, 2016 · Viewed 48.9k times · Source

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)

Answer

brian-brazil picture brian-brazil · Jan 21, 2016

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

rate(container_cpu_user_seconds_total[30s]) * 100