engine

package
v0.0.0-...-89d6517 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 31 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Duplicate label checking uses a bitmap supporting at most 64 steps.
	ErrStepsBatchTooLarge = errors.New("'StepsBatch' must not exceed 64")
)

Functions

func IsUnimplemented

func IsUnimplemented(err error) bool

func NewRemoteEngine

func NewRemoteEngine(opts Opts, q storage.Queryable, mint, maxt int64, labelSets []labels.Labels) *remoteEngine

Types

type AnalyzeOutputNode

type AnalyzeOutputNode struct {
	OperatorTelemetry telemetry.OperatorTelemetry `json:"telemetry,omitempty"`
	OperatorID        *uint64                     `json:"operatorId,omitempty"`
	Children          []*AnalyzeOutputNode        `json:"children,omitempty"`
	// contains filtered or unexported fields
}

func (*AnalyzeOutputNode) PeakSamples

func (a *AnalyzeOutputNode) PeakSamples() int64

func (*AnalyzeOutputNode) TotalSamples

func (a *AnalyzeOutputNode) TotalSamples() int64

func (*AnalyzeOutputNode) TotalSamplesPerStep

func (a *AnalyzeOutputNode) TotalSamplesPerStep() []int64

type DistributedEngine

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

func NewDistributedEngine

func NewDistributedEngine(opts Opts) *DistributedEngine

func (DistributedEngine) MakeInstantQuery

func (DistributedEngine) MakeInstantQueryFromPlan

func (l DistributedEngine) MakeInstantQueryFromPlan(ctx context.Context, q storage.Queryable, e api.RemoteEndpoints, opts promql.QueryOpts, plan logicalplan.Node, ts time.Time) (promql.Query, error)

func (DistributedEngine) MakeRangeQuery

func (l DistributedEngine) MakeRangeQuery(ctx context.Context, q storage.Queryable, e api.RemoteEndpoints, opts promql.QueryOpts, qs string, start, end time.Time, interval time.Duration) (promql.Query, error)

func (DistributedEngine) MakeRangeQueryFromPlan

func (l DistributedEngine) MakeRangeQueryFromPlan(ctx context.Context, q storage.Queryable, e api.RemoteEndpoints, opts promql.QueryOpts, plan logicalplan.Node, start, end time.Time, interval time.Duration) (promql.Query, error)

type Engine

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

func New

func New(opts Opts) *Engine

New creates a new query engine with the given options. The query engine will use the storage passed in NewInstantQuery and NewRangeQuery for retrieving data when executing queries.

Storage must support concurrent Select calls and SeriesSet iteration on a shared querier, as well as concurrent decoding of distinct sample iterators returned by that querier. The engine does not serialize storage access.

func NewWithScanners

func NewWithScanners(opts Opts, scanners engstorage.Scanners) *Engine

NewWithScanners creates a new query engine with the given options and storage.Scanners. When executing queries, the engine will create scanner operators using the storage.Scanners and will ignore the Prometheus storage passed in NewInstantQuery and NewRangeQuery. This method is useful when the data being queried does not easily fit into the Prometheus storage model.

func (*Engine) MakeInstantQuery

func (e *Engine) MakeInstantQuery(ctx context.Context, q storage.Queryable, opts *QueryOpts, qs string, ts time.Time) (promql.Query, error)

func (*Engine) MakeInstantQueryFromPlan

func (e *Engine) MakeInstantQueryFromPlan(ctx context.Context, q storage.Queryable, opts *QueryOpts, root logicalplan.Node, ts time.Time) (promql.Query, error)

func (*Engine) MakeRangeQuery

func (e *Engine) MakeRangeQuery(ctx context.Context, q storage.Queryable, opts *QueryOpts, qs string, start, end time.Time, step time.Duration) (promql.Query, error)

func (*Engine) MakeRangeQueryFromPlan

func (e *Engine) MakeRangeQueryFromPlan(ctx context.Context, q storage.Queryable, opts *QueryOpts, root logicalplan.Node, start, end time.Time, step time.Duration) (promql.Query, error)

func (*Engine) NewInstantQuery

func (e *Engine) NewInstantQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, ts time.Time) (promql.Query, error)

NewInstantQuery implements the promql.Engine interface.

func (*Engine) NewRangeQuery

func (e *Engine) NewRangeQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, start, end time.Time, step time.Duration) (promql.Query, error)

NewRangeQuery implements the promql.Engine interface.

type ExplainOutputNode

type ExplainOutputNode struct {
	OperatorName string              `json:"name,omitempty"`
	Children     []ExplainOutputNode `json:"children,omitempty"`
}

type ExplainableQuery

type ExplainableQuery interface {
	promql.Query

	Explain() *ExplainOutputNode
	Analyze() *AnalyzeOutputNode
}

type Opts

type Opts struct {
	Logger *slog.Logger
	Reg    prometheus.Registerer

	// MaxSamples limits the number of samples loaded by a query.
	MaxSamples int

	// Timeout limits the duration of query execution.
	Timeout time.Duration

	// ActiveQueryTracker tracks queries and limits concurrent execution.
	ActiveQueryTracker promql.QueryTracker

	// LookbackDelta is the maximum age of a sample selected by an instant vector selector.
	// Defaults to 5 minutes if not specified.
	LookbackDelta time.Duration

	// NoStepSubqueryIntervalFn returns the evaluation interval in milliseconds for
	// a subquery without an explicit step. Its argument is the range in milliseconds.
	NoStepSubqueryIntervalFn func(rangeMillis int64) int64

	// EnablePerStepStats enables per-step sample statistics.
	EnablePerStepStats bool

	// LogicalOptimizers are optimizers that are run if the value is not nil. If it is nil then the default optimizers are run. Default optimizer list is available in the logicalplan package.
	LogicalOptimizers []logicalplan.Optimizer

	// ExtLookbackDelta specifies what time range to use to determine valid previous sample for extended range functions.
	// Defaults to 1 hour if not specified.
	ExtLookbackDelta time.Duration

	// DecodingConcurrency is the maximum number of goroutines that can be used to decode samples. Defaults to GOMAXPROCS / 2.
	DecodingConcurrency int

	// SelectorBatchSize specifies the maximum number of samples to be returned by selectors in a single batch.
	SelectorBatchSize int64

	// EnableExperimentalFunctions enables parsing of experimental PromQL functions
	// and aggregations. Defaults to false.
	EnableExperimentalFunctions bool

	// EnableXFunctions enables custom xRate, xIncrease and xDelta functions.
	// This will default to false.
	EnableXFunctions bool

	// EnableAnalysis enables query analysis.
	EnableAnalysis bool

	// The Prometheus engine has internal check for duplicate labels produced by functions, aggregations or binary operators.
	// This check can produce false positives when querying time-series data which does not conform to the Prometheus data model,
	// and can be disabled if it leads to false positives.
	DisableDuplicateLabelChecks bool
}

Opts configures the query engine. Only options supported by this engine are exposed.

type Query

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

func (*Query) Analyze

func (q *Query) Analyze() *AnalyzeOutputNode

func (*Query) Explain

func (q *Query) Explain() *ExplainOutputNode

Explain returns human-readable explanation of the created executor.

type QueryOpts

type QueryOpts struct {
	// These values are used to implement promql.QueryOpts, they have weird "Param" suffix because
	// they are accessed by methods of the same name.
	LookbackDeltaParam      time.Duration
	EnablePerStepStatsParam bool

	// DecodingConcurrency can be used to override the DecodingConcurrency engine setting.
	DecodingConcurrency int

	// SelectorBatchSize can be used to override the SelectorBatchSize engine setting.
	SelectorBatchSize int64

	// LogicalOptimizers can be used to override the LogicalOptimizers engine setting.
	LogicalOptimizers []logicalplan.Optimizer
}

QueryOpts implements promql.QueryOpts but allows to override more engine default options.

func (QueryOpts) EnablePerStepStats

func (opts QueryOpts) EnablePerStepStats() bool

func (QueryOpts) LookbackDelta

func (opts QueryOpts) LookbackDelta() time.Duration

func (QueryOpts) UseStartTimestamps

func (QueryOpts) UseStartTimestamps() *bool

UseStartTimestamps disables unsupported start-timestamp evaluation.

type QueryType

type QueryType int
const (
	InstantQuery QueryType = 1
	RangeQuery   QueryType = 2
)

Jump to

Keyboard shortcuts

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