Prometheus Query: Calculate Container CPU Usage by Pod
The given Prometheus query calculates the sum of the instant rate of the container CPU usage within the last 5 minutes and multiplies it by 100. It then groups the result by the pod./n/nThe query can be explained as follows:/n/n- 'irate(container_cpu_usage_seconds_total{container='/$Container',instance='/$Node',pod='/$Pod'}[5m])': This part of the query calculates the instant rate of the container CPU usage within the last 5 minutes. The 'container_cpu_usage_seconds_total' metric is filtered by the specified container, instance, and pod labels. The 'irate' function calculates the per-second rate of change of the metric over time./n/n- 'sum(...)': The 'sum' function is used to calculate the sum of the instant rate of the container CPU usage./n/n- '*100': The sum of the instant rate is multiplied by 100./n/n- 'by(pod)': The result is grouped by the pod label. This means that the final result will provide the sum of the instant rate of the container CPU usage multiplied by 100 for each pod.
原文地址: https://www.cveoy.top/t/topic/piTd 著作权归作者所有。请勿转载和采集!