What is aggregation in PromQL (sum, avg, by, without)? [Basic]
Answer
Aggregation in PromQL combines series using functions such as sum, avg, min, max, count, topk, and quantile. The by clause keeps selected labels; without drops selected labels and groups by the rest.
Technical explanation
sum by (service) groups all matching series into one result per service.
sum without(instance, pod) removes replica-level labels while keeping the other labels.
Correct aggregation is essential to avoid double counting or accidentally hiding a bad instance.
Hands-on example
Examples: sum(rate(http_requests_total[5m])) by (service) gives RPS per service. sum without(pod, instance) (rate(container_cpu_usage_seconds_total[5m])) aggregates away pod identity. topk(10, sum by (pod) (rate(container_cpu_usage_seconds_total[5m]))) finds top CPU consumers.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Observability interview questions
- How do you compute a 95th percentile latency from a histogram in PromQL (histogram_quantile)? [Basic]
- What is a recording rule, and when would you use one? [Basic]
- What is the difference between rate() and irate()? [Basic]
- What is an alerting rule, and how does it differ from a recording rule? [Basic]
- What is PromQL, and what is an instant vector versus a range vector? [Basic]
- What is the Pushgateway, and why is it discouraged for most cases? [Basic]
- What is the difference between an exporter and instrumenting your app directly? [Basic]
- How does Prometheus handle high cardinality, and why is it a problem? [Intermediate]