Interview Prep/Monitoring & Observability/Rapid-Fire PromQL & LogQL

Top 5 pods by CPU usage in a namespace?

BeginnerProductionRapid-Fire PromQL & LogQL
Answer
topk(5, sum by (pod) (rate(container_cpu_usage_seconds_total{namespace="shop", container!=""}[5m])))

container!="" removes the pod-level cgroup series that would double-count.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Rapid-Fire PromQL & LogQL