How do PromQL aggregation operators and `by`/`without` work?
BeginnerConceptPromQL & Recording Rules
Answer
Operators: sum, avg, min, max, count, stddev, stdvar, topk, bottomk, quantile, count_values, group, and in 3.x limitk/limit_ratio (experimental).
sum by (namespace) (rate(container_cpu_usage_seconds_total[5m]))
sum without (instance, pod) (rate(http_requests_total[5m]))
topk(5, sum by (pod) (container_memory_working_set_bytes))
by keeps only the listed labels; without drops the listed ones and keeps the rest.
More on PromQL & Recording Rules
What are the PromQL data types?BeginnerWhat label matchers does PromQL support?BeginnerExplain `rate()`.Beginner`rate()` vs `irate()`: what is the difference?IntermediateWhat does `increase()` return and why is it sometimes a non-integer?IntermediateWhy must you `rate()` before `sum()`, never the reverse?Intermediate