← Lessons

quiz vs the machine

Gold1480

System Design

The Query Language PromQL

Selecting, ranging, and aggregating time series in a metrics query language.

5 min read · core · beat Gold to climb

A language for series

A metrics query language like PromQL is built to select series by labels and compute over time. Its core types are the instant vector, a value per series at one moment, and the range vector, a window of values per series.

Core operations

  • Selectors pick series by metric name and label matchers.
  • Range selectors grab a time window for rate like functions.
  • Rate turns a monotonically increasing counter into a per second value over a window.
  • Aggregations like sum and average collapse across series, optionally grouped by a label.

A typical query shape

You select a counter, wrap it in a rate over a window to get per second throughput, then aggregate by a dimension such as region to compare areas.

Why counters need rate

Counters only ever go up and reset on restart. Applying rate computes the increase per second and transparently handles resets, which raw subtraction would not.

Key idea

A metrics query language selects series by labels and works with instant and range vectors, using rate for counters and aggregations grouped by dimension.

Check yourself

Answer to earn rating on the learn ladder.

1. Why is rate applied to counter metrics?

2. What is a range vector?