Skip to main content

Module matcher

Module matcher 

Source
Expand description

Label matchers and the postings plan they compile to.

A LabelMatcher is the low-level matcher type Prometheus uses: a label name, a match type and a value. PromQL AST nodes are not represented here — a query layer converts its own matchers into this type.

Semantics worth calling out, because they decide which series a matcher selects:

  • a missing label is treated as the empty string, so {foo=""} matches series without foo, and {foo!=""} matches only series that have a non-empty foo;
  • =~ and !~ are fully anchored, i.e. =~"a|b" matches a and b but not ab. Prometheus does the same;
  • =~".*" matches everything and =~".+" matches any non-empty value; both are special-cased in the planner instead of scanning every value.

IndexReader::postings_for_matchers turns a matcher list into a single lazy postings source, mirroring Prometheus’ PostingsForMatchers: matchers that must hold are intersected, matchers that exclude are subtracted, and the choice of “start from all series” is made the same way.

Structs§

LabelMatcher
A label matcher: name <op> value.

Enums§

MatchType
How a LabelMatcher compares a label value.