Skip to main content
In this lesson we cover PromQL aggregation operators — functions that combine the elements of an instant vector to produce a new instant vector (often with fewer series). Aggregations are useful for producing totals, averages, min/max values, and group-based rollups across label dimensions.
A presentation slide titled "Aggregation operators" showing a brief explanation of aggregating instant vectors and a table listing aggregator functions (Sum, Min, Max, Avg, Group, Stddev, etc.) with their descriptions. The words "aggregate" and "fewer" are highlighted in the header text.
Aggregation operators reduce an instant vector into coarser results. Use by(...) to keep specific labels in the output, or without(...) to drop labels from the aggregation key.

Common aggregation functions

Simple aggregation examples

Given an http_requests instant vector (each line is a distinct series sample):
A plain aggregation over the whole set:
Other straightforward reductions:

Grouping results with by(...)

To aggregate while preserving one or more label dimensions, use by(...). Series that share the listed labels are combined. Example: group by path to sum requests per path:
Group by method to get totals per HTTP method:

Multi-label grouping

If time series include an instance label (two nodes: node1 and node2), the dataset might look like:
You can aggregate by both instance and method:

The without(...) clause

without(...) is the inverse of by(...) — it tells Prometheus which labels to exclude from the aggregation key. The result keeps all other labels. Using the dataset above, sum without(path) (http_requests) removes the path label and aggregates across that dimension. For this dataset it is equivalent to sum by(instance, method) (http_requests):
Be cautious when grouping by high-cardinality labels (for example, pod, instance, or user IDs): by(...) can produce many result series and increase memory/CPU usage. Prefer grouping by stable, low-cardinality labels for dashboards and alerts.

Real-world example: CPU seconds

Consider node_cpu_seconds_total, where each series has labels like instance, cpu, mode, and job:
A plain sum(node_cpu_seconds_total) aggregates every CPU and instance into a single number. More useful rollups:
  • Total CPU seconds per instance:
  • Totals per CPU per instance:
  • Keep instance and job but drop cpu and mode:

Quick reference

Summary: Aggregation operators let you reduce instant vectors into summarized results. Use by(...) to declare which labels to preserve in the result, and without(...) to remove labels from the aggregation key — both are essential for meaningful, efficient rollups in Prometheus queries.

Watch Video

Practice Lab