Search code examples
kubernetesprometheusgrafanacpu-usagepromql

How to modify the promql query to get sum of CPU usages of the all the pods belong to one service?


How to modify the promql query to get the sum of all the pods (replicas) CPU usage belonging to one particular service?

To get the CPU usage of a single pod I use the following query :

rate(container_cpu_usage_seconds_total{pod="pod name",container="container name"}[5m]) by (container)

How can I modify this?


Solution

  • You can use sum(rate(container_cpu_usage_seconds_total{pod="pod name",container="container name"}[5m])) by (container) to get the sum of all the pods (replicas) CPU usage belonging to one particular service.