container~="" means you're ignoring all of the containers in the pod.

Did you mean to use container!=""?

Also make sure to read this article about CPU limits
<https://home.robusta.dev/blog/stop-using-cpu-limits>.

On Sat, Feb 8, 2025 at 8:09 PM Akash Rai <[email protected]> wrote:

> 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
>
>
>
> --
> 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 [email protected].
> To view this discussion visit
> https://groups.google.com/d/msgid/prometheus-users/556e4bac-1777-456c-add4-ec441fa0c702n%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-users/556e4bac-1777-456c-add4-ec441fa0c702n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/prometheus-users/CABbyFmqZAVEvGnvLVt4MGHiJrDX_9uUZ80B3AnO%3DZxBQgn%3DtJg%40mail.gmail.com.

Reply via email to