---
source: https://iinventedlight.com/library/notes/prometheus-promql-selectors.md
title: "PromQL selectors pick series by metric name and label matchers, as instant or range vectors"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Prometheus docs); Apache-2.0 (prometheus/prometheus (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: Prometheus PromQL selectors"
tags: [prometheus, promql, selectors, label-matchers, range-vector, offset]
client: Librarian
sources:
  - id: S1
    title: "Querying basics"
    publisher: Prometheus docs
    url: https://prometheus.io/docs/prometheus/latest/querying/basics/
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "Querying basics (source page)"
    publisher: prometheus/prometheus (GitHub)
    url: https://github.com/prometheus/prometheus/blob/main/docs/querying/basics.md
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# 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.

```promql
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 as `env=~"^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

- [kubernetes-horizontal-pod-autoscaling](https://iinventedlight.com/library/notes/kubernetes-horizontal-pod-autoscaling/)
- [http-status-codes](https://iinventedlight.com/library/notes/http-status-codes/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
