How to get the total CPU usage of all the replicas belong to one service

Viewed 22

I have an application running on 3 pods (one container per pod) in a Kubernetes cluster. Let's say Pod A is the front end and 2 separate Pods (Pod B and Pod C) connected to Pod A. Similar to the following figure. enter image description here

I am using Kubernetes HPA to scale these pods based on CPU usage. But I want to monitor the Total CPU usage (or CPU millicores) per service during scaling. That means if there are 3 replicas of Pod B, I want to monitor the sum of all the CPU millicores of Pod B replicas from Grafana. I already have Prometheus and Grafana running in the cluster. I want to know whether there is a PromQL query to get the CPU usage per service. Right now I have to query the CPU usage per pod manually like this

rate(container_cpu_usage_seconds_total{pod="pod name"}[5m]
0 Answers
Related