rate(container_cpu_usage_seconds_total) is in cpu-seconds per second, or 
cpus.
container_spec_cpu_quota  /  container_spec_cpu_period is also in cpus.
Therefore the ratio is unitless, just a fraction.

To see it as a percentage, multiply by 100.

Bryan

On Wednesday, 22 November 2023 at 13:10:35 UTC lrans...@gmail.com wrote:

> Hi all,
> I am looking for metric expression for CPU usage of pod in percentage in 
> kubernetes. I found following expression from the blog but the result is 
> coming in seconds instead of percentage. Kindly suggest how we can get CPU 
> utilization in percentage, Thanks
>
> sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", 
> image!="", container_name!="POD"}[5m])) by (pod_name, container_name) / 
> sum(container_spec_cpu_quota{name!~".*prometheus.*", image!="", 
> container_name!="POD"}/container_spec_cpu_period{name!~".*prometheus.*", 
> image!="", container_name!="POD"}) by (pod_name, container_name)
>

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/0088a59e-b74c-4adb-86da-5cd398de9461n%40googlegroups.com.

Reply via email to