Verifying CPU Usage % and Memory Usage % of all pods from prometheus data source on Grafana with cluster

36 views
Skip to first unread message

Akash Rai

unread,
Feb 8, 2025, 2:09:01 PM2/8/25
to Prometheus Users
Hi Team,
I am new to Prometheus 
I have written PromQL to get pod name when cpu and memory usage is more than 80%

CPU Usage Expression
sum(rate(container_cpu_usage_seconds_total{container~=""}[5m])) by (pod) / sum(kube_pod_container_resource_limits{resource="cpu"}) by (pod) * 100 > 80

Output am getting for few pods as follow
pod1 0.0775
pod2 0.599

But when i check from pod bash terminal using top command i see 6.2%~8.2%us

Memory Usage Expression
sum(container_memory_working_set_bytes{container!=""}) by (pod)/sum(container_spec_memory_limit_bytes{container!=""}) by (pod) * 100 > 80

In grafana i see output 23.4
but in pod bash terminal when i calculate % of memory usage using top command it is more than 50%.

Please help me here how can i get all the pod name which is consuming more than 80% of memory and more than 80% of CPU

Regards,
Akash



Ben Kochie

unread,
Feb 8, 2025, 2:28:37 PM2/8/25
to Akash Rai, Prometheus Users
container~="" means you're ignoring all of the containers in the pod.

Did you mean to use container!=""?


--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/prometheus-users/556e4bac-1777-456c-add4-ec441fa0c702n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages