Prometheus Monitoring - CPU Usage %

446 views
Skip to first unread message

Bill Zalokostas

unread,
Apr 1, 2021, 9:11:19 AM4/1/21
to Prometheus Users
The type sum by(image) (rate(container_cpu_usage_seconds_total{image="my-image-name"}[5m])) * 100 is returning seconds or Mhz? I want to get this CPU usage metric from prometheus and use custom metric in my autoscaler in order to deploy or delete replicas in the slave-node, so I have to Mhz. Is there any solution here?

Thank you in advance


Ben Kochie

unread,
Apr 1, 2021, 9:56:51 AM4/1/21
to Bill Zalokostas, Prometheus Users
CPU use is never measured in "Mhz". Linux, and hence containers, only record CPU use in "CPU Seconds", the frequency of the clock is not part of the data.

On Thu, Apr 1, 2021 at 3:11 PM Bill Zalokostas <billzal...@gmail.com> wrote:
The type sum by(image) (rate(container_cpu_usage_seconds_total{image="my-image-name"}[5m])) * 100 is returning seconds or Mhz? I want to get this CPU usage metric from prometheus and use custom metric in my autoscaler in order to deploy or delete replicas in the slave-node, so I have to Mhz. Is there any solution here?

Thank you in advance


--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/fb237952-2939-49a5-bf88-f04de9eef4b6n%40googlegroups.com.

Julius Volz

unread,
Apr 1, 2021, 10:38:24 AM4/1/21
to Ben Kochie, Bill Zalokostas, Prometheus Users
Yeah, that initial expression gives you the CPU usage in percent of a CPU core (not seconds or MHz). So if you have 1 core and it's 100% used, you will get an output value of 100, for 2 fully used cores you would get 200, etc.

It doesn't seem like cAdvisor exposes any clock speed (MHz) metrics, see also https://github.com/google/cadvisor/issues/2354. Though the Node Exporter does (see https://www.robustperception.io/cpu-frequency-scaling-metrics-from-the-node-exporter), but how much sense it makes to combine that with the container-level CPU usage data, I'm not sure.



--
Julius Volz
PromLabs - promlabs.com
Reply all
Reply to author
Forward
0 new messages