PromQL selectors pick series by metric name and label matchers, as instant or range vectors
Answer: An instant vector selector such as http_requests_total{job="api"} selects a set of time series with one sample value each at a given timestamp. Append a duration in square brackets, as in [5m], to get a range vector that selects a range of samples back from the current instant.
Label matching operators
=: labels exactly equal to the provided string.!=: labels not equal to the provided string.=~: labels that regex-match the provided string.!~: labels that do not regex-match the provided string.
http_requests_total{environment=~"staging|testing|development",method!="GET"}
rate(http_requests_total[5m])
http_requests_total offset 5m
Rules that bite
- Regex matches are fully anchored:
env=~"foo"is treated asenv=~"^foo$". - A matcher that matches empty label values also selects every time series where that label is not set at all.
- Every vector selector needs a name, or at least one label matcher that does not match the empty string;
{job=~".*"}is illegal. - When several matchers name the same label, they all must pass for a result to be returned.
offset and duration expressions
The offset modifier changes the time offset for individual instant and range vectors in a query. Arithmetic expressions can be used where a time duration is expected, for example [5m * 2]. With offset, wrap a duration expression in parentheses; without them, only the first duration value is used.
See also
Claims
- id: C1 claim: Instant vector selectors select series with one sample at a timestamp. source: S1 evidence: "Instant vector selectors allow the selection of a set of time series"
- id: C2 claim: Regex matches are fully anchored. source: S2 evidence: "Regex](#regular-expressions) matches are fully anchored."
- id: C3 claim: Selectors need a name or a non-empty-matching label matcher. source: S2 evidence: "Vector selectors must either specify a name or at least one label matcher"
- id: C4 claim: offset changes the time offset for vectors in a query. source: S2 evidence: "modifier allows changing the time offset for individual instant and range vectors"
Sources
- [S1] Querying basics. Prometheus docs. https://prometheus.io/docs/prometheus/latest/querying/basics/ . License: Apache-2.0. Accessed 2026-11-18.
- [S2] Querying basics (source page). prometheus/prometheus (GitHub). https://github.com/prometheus/prometheus/blob/main/docs/querying/basics.md . License: Apache-2.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Prometheus docs, Querying basics; prometheus/prometheus (GitHub), Querying basics (source page). Apache-2.0 (https://raw.githubusercontent.com/prometheus/prometheus/main/LICENSE). Copyright The Prometheus Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Prometheus docs, Querying basics; prometheus/prometheus (GitHub), Querying basics (source page). Apache-2.0 (https://raw.githubusercontent.com/prometheus/prometheus/main/LICENSE). Copyright The Prometheus Authors.
Cite this
iinventedlight. 2026. "PromQL selectors pick series by metric name and label matchers, as instant or range vectors." iinventedlight Library, iil:note:64thp1zg, version of 2026-11-18. https://iinventedlight.com/library/notes/prometheus-promql-selectors/. License: CC-BY-4.0.
@misc{iil_note_64thp1zg,
author = {{iinventedlight}},
title = {{PromQL selectors pick series by metric name and label matchers, as instant or range vectors}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/prometheus-promql-selectors/},
note = {Permanent ID iil:note:64thp1zg. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- prometheus-promql-selectors.table.json (table; CC-BY-4.0)
- prometheus-promql-selectors.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/prometheus-promql-selectors.md.