TimelessMetrics.LabelMatch (timeless_metrics v6.2.2)

Copy Markdown View Source

Shared label-filter matching for query paths (both engines).

Filter entries take the shapes produced by the PromQL parser and native HTTP params:

  • {key, "value"} — exact match
  • {key, {:regex, pattern}} — anchored regex match
  • {key, {:not_equal, "value"}} — negation
  • {key, {:not_regex, pattern}} — anchored regex negation

Semantics follow Prometheus: a series that lacks the label is treated as having the empty-string value, so label!="v" and label=~".*" match series without the label, and label="" matches only series without it. Invalid regex patterns match nothing (the query layer is expected to reject them earlier).

Summary

Functions

Pre-compile the regex entries of a filter. Returns an opaque compiled filter for match?/2.

Does a series' label map satisfy every entry of a compiled filter?

Split a filter into {equality_map, complex_entries} where the equality map contains only non-empty exact matches (safe to push down to storage lookups keyed on present labels) and complex entries need match?/2 post-filtering.

Functions

compile(label_filter)

Pre-compile the regex entries of a filter. Returns an opaque compiled filter for match?/2.

match?(labels, compiled_filter)

Does a series' label map satisfy every entry of a compiled filter?

split_pushdown(label_filter)

Split a filter into {equality_map, complex_entries} where the equality map contains only non-empty exact matches (safe to push down to storage lookups keyed on present labels) and complex entries need match?/2 post-filtering.