How to Monitor Kubernetes CPU Limits, Memory Limits and Replicas in Grafana

By now, you've probably already given your developers access to CPU and memory usage dashboards.

The next thing they'll usually ask is "What resource limits does this application have?" or "How many replicas are currently running?"

Instead of answering those questions repeatedly, you can add the following Grafana Table panels to your dashboard and let developers find the answers themselves.

View Deployment Memory Limits

Add a Table panel and use the following Prometheus query:

kube_pod_container_resource_limits{resource="memory",namespace=~"^$namespace$",container=~".*"}

This query displays the memory limits configured for every container running in the selected namespace.

View Deployment CPU Limits

Use the following query to display the CPU limits configured for each container in the selected namespace.

kube_pod_container_resource_limits{resource="cpu",namespace=~"^$namespace$",container=~".*"} * 1000

The multiplication by 1000 converts CPU cores into millicores (mCPU), making the values easier to compare with Kubernetes resource requests and limits.

View Deployment Replica Count

Use the following query to display the desired replica count for every deployment in the selected namespace.

kube_deployment_spec_replicas{namespace=~"^$namespace$",pod=~".*"}

This table shows how many replicas each deployment is configured to maintain.

Adding these tables gives developers a much more complete view of their workloads and significantly reduces the number of "Can you quickly check something for me?" messages landing in your Teams chat.

#grafana #prometheus #monitoring

0 Comments