stefanprodan / dockprom

Docker hosts and containers monitoring with Prometheus, Grafana, cAdvisor, NodeExporter and AlertManager
MIT License
6.02k stars 1.72k forks source link

understaing the meaning of cpu usage graph in grafana #291

Closed carlosjpr-collab closed 7 months ago

carlosjpr-collab commented 10 months ago

Hi,

I am inquiring about the meaning of the 2% container CPU usage metric.

image

Since I have 16 cores, does it imply that this container is utilizing 0.02 * 16 = 0.32 CPU? Is that correct? What about CPU load? Any information that could help us understand would be appreciated.

Thank you.

patrickfenn commented 7 months ago

Hi, I do not work on this project, but I do work on operating systems professionally, so I think I can explain. The way these resource monitors work is that it scans the /proc/ fs, and takes a snapshot of resource usage. They can then calculate total load by taking the difference of system uptime and total cpu time. Since they do not have per core breakdown, it is possible that this is just a single core. Since procs are schedules on the cpu at a per quantum basis (some exceptions), load is only determined by time spent on cpu.

Ie, the system has spent 3.51% of time on cpu in the last interval it was polled (whatever that is set at).

nightah commented 7 months ago

You can also get a good explanation of each query by toggling the Explain button and also looking at the definition of said metric (in this case cAdvisor's container_cpu_user_seconds_total:

image