promql

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package promql is an optional adapter that bridges the storage fetch contract (query/fetch) to the Prometheus storage.Queryable interface. It does not own a PromQL engine: the embedder (e.g. go-faster/oteldb, which already has PromQL/LogQL/TraceQL engines) drives its own promql.Engine over the Queryable this package returns. The storage library proper stops at the fetch seam and stays language- and Prometheus-free; this package is the only one importing github.com/prometheus/prometheus, and importing it is opt-in.

Condition extraction lives here (the language layer), never in storage: a Prometheus matcher that can match the empty string (e.g. `!=`, `!~`, `=""`) would wrongly exclude series that lack the label if pushed into the postings index, so only index-safe matchers are pushed down; every returned series is then re-checked against the full matcher set.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchesAll added in v0.9.0

func MatchesAll(lset labels.Labels, ms []*labels.Matcher) bool

MatchesAll reports whether a series' labels satisfy every matcher, treating an absent label as the empty string (Prometheus semantics). It is the post-fetch re-check companion to PushableMatchers: exported so an embedder's pushdown path re-checks the full matcher set the same way Queryable does.

func PromLabels added in v0.9.0

func PromLabels(s signal.Series) labels.Labels

PromLabels projects a storage series identity to a Prometheus label set: every resource, scope, and (folded) point attribute becomes a label, with the internal reserved labels (except __name__) hidden. Scope name/version are exposed under the otel.scope.* keys, the same labels the head indexes.

PromLabels is exported so an embedder can render a signal.Series (e.g. the identity carried alongside an github.com/oteldb/storage.Storage.AggregateMetrics result) as PromQL labels without duplicating this projection.

func PushableMatchers added in v0.9.0

func PushableMatchers(ms []*labels.Matcher) []fetch.Matcher

PushableMatchers returns fetch matchers for the index-safe subset: matchers that do not match the empty string. A matcher that matches "" (negated/absent) cannot prune via the postings index without wrongly dropping series that lack the label, so it is enforced only by the post-fetch re-check in MatchesAll.

It is exported so an embedder building a pushdown path over the fetch/aggregate seam (e.g. oteldb's *_over_time aggregate pushdown) can lower the same index-safe matcher set the Queryable uses, keeping matcher translation in one place.

Types

type Queryable

type Queryable struct {
	// contains filtered or unexported fields
}

Queryable adapts a fetch.Fetcher (one tenant's engine) to the Prometheus storage.Queryable interface for a single tenant.

func NewQueryable

func NewQueryable(fetcher fetch.Fetcher, tenant signal.TenantID) *Queryable

NewQueryable returns a Prometheus storage.Queryable backed by fetcher for the given tenant. A single Queryable reused across queries (the embedder's per-tenant adapter) memoizes label projections, so repeated queries pay the projection cost once per series.

func (*Queryable) Querier

func (q *Queryable) Querier(mint, maxt int64) (storage.Querier, error)

Querier returns a querier over [mint, maxt] (Prometheus milliseconds).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL