Kubernetes Pod CPU Usage Calculation with Prometheus
The given query calculates the sum of CPU usage in percentage for each Kubernetes pod over the past 5 minutes.
Here's the query:
sum by (container_label_io_kubernetes_pod_name)(irate(container_cpu_usage_seconds_total[5m])*100)
Explanation:
irate(container_cpu_usage_seconds_total[5m])calculates the per-second rate of change of the 'container_cpu_usage_seconds_total' metric over the past 5 minutes.*100multiplies the rate by 100 to convert it to a percentage.sum by (container_label_io_kubernetes_pod_name)groups the result by the 'container_label_io_kubernetes_pod_name' label, calculating the sum of CPU usage for each unique pod name.
Note: The 'container_label_io_kubernetes_pod_name' is an example label. You may need to replace it with the appropriate label name for your metric.
原文地址: https://www.cveoy.top/t/topic/piS3 著作权归作者所有。请勿转载和采集!