Documentation ¶
Index ¶
- Variables
- func NewOriginContext(ctx context.Context, data map[string]interface{}) context.Context
- func PreprocessExpr(expr parser.Expr, start, end time.Time) parser.Expr
- type ActiveQueryTracker
- type Engine
- type EngineOpts
- type Entry
- type ErrQueryCanceled
- type ErrQueryTimeout
- type ErrStorage
- type ErrTooManySamples
- type EvalNodeHelper
- type FunctionCall
- type LazyLoader
- type Matrix
- type Point
- type Query
- type QueryLogger
- type QueryOrigin
- type Result
- type Sample
- type Scalar
- type Series
- type StorageSeries
- type String
- type Test
- type Vector
Constants ¶
This section is empty.
Variables ¶
var AtModifierUnsafeFunctions = map[string]struct{}{
"days_in_month": {}, "day_of_month": {}, "day_of_week": {},
"hour": {}, "minute": {}, "month": {}, "year": {},
"predict_linear": {}, "time": {},
"timestamp": {},
}
AtModifierUnsafeFunctions are the functions whose result can vary if evaluation time is changed when the arguments are step invariant. It also includes functions that use the timestamps of the passed instant vector argument to calculate a result since that can also change with change in eval time.
var ErrValidationAtModifierDisabled = errors.New("@ modifier is disabled")
var FunctionCalls = map[string]FunctionCall{
"abs": funcAbs,
"absent": funcAbsent,
"absent_over_time": funcAbsentOverTime,
"avg_over_time": funcAvgOverTime,
"ceil": funcCeil,
"changes": funcChanges,
"clamp_max": funcClampMax,
"clamp_min": funcClampMin,
"count_over_time": funcCountOverTime,
"days_in_month": funcDaysInMonth,
"day_of_month": funcDayOfMonth,
"day_of_week": funcDayOfWeek,
"delta": funcDelta,
"deriv": funcDeriv,
"exp": funcExp,
"floor": funcFloor,
"histogram_quantile": funcHistogramQuantile,
"holt_winters": funcHoltWinters,
"hour": funcHour,
"idelta": funcIdelta,
"increase": funcIncrease,
"irate": funcIrate,
"label_replace": funcLabelReplace,
"label_join": funcLabelJoin,
"ln": funcLn,
"log10": funcLog10,
"log2": funcLog2,
"max_over_time": funcMaxOverTime,
"min_over_time": funcMinOverTime,
"minute": funcMinute,
"month": funcMonth,
"predict_linear": funcPredictLinear,
"quantile_over_time": funcQuantileOverTime,
"rate": funcRate,
"resets": funcResets,
"round": funcRound,
"scalar": funcScalar,
"sort": funcSort,
"sort_desc": funcSortDesc,
"sqrt": funcSqrt,
"stddev_over_time": funcStddevOverTime,
"stdvar_over_time": funcStdvarOverTime,
"sum_over_time": funcSumOverTime,
"time": funcTime,
"timestamp": funcTimestamp,
"vector": funcVector,
"year": funcYear,
}
FunctionCalls is a list of all functions supported by PromQL, including their types.
Functions ¶
func NewOriginContext ¶ added in v1.25.3
NewOriginContext returns a new context with data about the origin attached.
Types ¶
type ActiveQueryTracker ¶ added in v1.25.3
type ActiveQueryTracker struct {
// contains filtered or unexported fields
}
func NewActiveQueryTracker ¶ added in v1.25.3
func NewActiveQueryTracker(localStoragePath string, maxConcurrent int, logger log.Logger) *ActiveQueryTracker
func (ActiveQueryTracker) Delete ¶ added in v1.25.3
func (tracker ActiveQueryTracker) Delete(insertIndex int)
func (ActiveQueryTracker) GetMaxConcurrent ¶ added in v1.25.3
func (tracker ActiveQueryTracker) GetMaxConcurrent() int
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine handles the lifetime of queries from beginning to end. It is connected to a querier.
func (*Engine) NewInstantQuery ¶
NewInstantQuery returns an evaluation query for the given expression at the given time.
func (*Engine) NewRangeQuery ¶
func (ng *Engine) NewRangeQuery(q storage.Queryable, qs string, start, end time.Time, interval time.Duration) (Query, error)
NewRangeQuery returns an evaluation query for the given time range and with the resolution set by the interval.
func (*Engine) SetQueryLogger ¶ added in v1.25.3
func (ng *Engine) SetQueryLogger(l QueryLogger)
SetQueryLogger sets the query logger.
type EngineOpts ¶ added in v1.25.3
type EngineOpts struct { Logger log.Logger Reg prometheus.Registerer MaxSamples int Timeout time.Duration ActiveQueryTracker *ActiveQueryTracker // LookbackDelta determines the time since the last sample after which a time // series is considered stale. LookbackDelta time.Duration // NoStepSubqueryIntervalFn is the default evaluation interval of // a subquery in milliseconds if no step in range vector was specified `[30m:<step>]`. NoStepSubqueryIntervalFn func(rangeMillis int64) int64 // EnableAtModifier if true enables @ modifier. Disabled otherwise. EnableAtModifier bool }
EngineOpts contains configuration options used when creating a new Engine.
type ErrQueryCanceled ¶
type ErrQueryCanceled string
ErrQueryCanceled is returned if a query was canceled during processing.
func (ErrQueryCanceled) Error ¶
func (e ErrQueryCanceled) Error() string
type ErrQueryTimeout ¶
type ErrQueryTimeout string
ErrQueryTimeout is returned if a query timed out during processing.
func (ErrQueryTimeout) Error ¶
func (e ErrQueryTimeout) Error() string
type ErrStorage ¶ added in v1.6.0
type ErrStorage struct{ Err error }
ErrStorage is returned if an error was encountered in the storage layer during query handling.
func (ErrStorage) Error ¶ added in v1.25.3
func (e ErrStorage) Error() string
type ErrTooManySamples ¶ added in v1.25.3
type ErrTooManySamples string
ErrTooManySamples is returned if a query would load more than the maximum allowed samples into memory.
func (ErrTooManySamples) Error ¶ added in v1.25.3
func (e ErrTooManySamples) Error() string
type EvalNodeHelper ¶ added in v1.25.3
type EvalNodeHelper struct { // Evaluation timestamp. Ts int64 // Vector that can be used for output. Out Vector // Caches. // DropMetricName and label_*. Dmn map[uint64]labels.Labels // contains filtered or unexported fields }
EvalNodeHelper stores extra information and caches for evaluating a single node across steps.
func (*EvalNodeHelper) DropMetricName ¶ added in v1.25.3
func (enh *EvalNodeHelper) DropMetricName(l labels.Labels) labels.Labels
DropMetricName is a cached version of DropMetricName.
type FunctionCall ¶ added in v1.25.3
type FunctionCall func(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector
FunctionCall is the type of a PromQL function implementation
vals is a list of the evaluated arguments for the function call.
For range vectors it will be a Matrix with one series, instant vectors a Vector, scalars a Vector with one series whose value is the scalar value,and nil for strings.
args are the original arguments to the function, where you can access
matrixSelectors, vectorSelectors, and StringLiterals.
enh.Out is a pre-allocated empty vector that you may use to accumulate
output before returning it. The vectors in vals should not be returned.a
Range vector functions need only return a vector with the right value,
the metric and timestamp are not needed.
Instant vector functions need only return a vector with the right values and
metrics, the timestamp are not needed.
Scalar results should be returned as the value of a sample in a Vector.
type LazyLoader ¶ added in v1.25.3
type LazyLoader struct { testutil.T SubqueryInterval time.Duration // contains filtered or unexported fields }
LazyLoader lazily loads samples into storage. This is specifically implemented for unit testing of rules.
func NewLazyLoader ¶ added in v1.25.3
func NewLazyLoader(t testutil.T, input string) (*LazyLoader, error)
NewLazyLoader returns an initialized empty LazyLoader.
func (*LazyLoader) Close ¶ added in v1.25.3
func (ll *LazyLoader) Close()
Close closes resources associated with the LazyLoader.
func (*LazyLoader) Context ¶ added in v1.25.3
func (ll *LazyLoader) Context() context.Context
Context returns the LazyLoader's context.
func (*LazyLoader) QueryEngine ¶ added in v1.25.3
func (ll *LazyLoader) QueryEngine() *Engine
QueryEngine returns the LazyLoader's query engine.
func (*LazyLoader) Queryable ¶ added in v1.25.3
func (ll *LazyLoader) Queryable() storage.Queryable
Queryable allows querying the LazyLoader's data. Note: only the samples till the max timestamp used
in `WithSamplesTill` can be queried.
func (*LazyLoader) Storage ¶ added in v1.25.3
func (ll *LazyLoader) Storage() storage.Storage
Storage returns the LazyLoader's storage.
func (*LazyLoader) WithSamplesTill ¶ added in v1.25.3
func (ll *LazyLoader) WithSamplesTill(ts time.Time, fn func(error))
WithSamplesTill loads the samples till given timestamp and executes the given function.
type Matrix ¶ added in v1.25.3
type Matrix []Series
Matrix is a slice of Series that implements sort.Interface and has a String method.
func (Matrix) ContainsSameLabelset ¶ added in v1.25.3
ContainsSameLabelset checks if a matrix has samples with the same labelset Such a behavior is semantically undefined https://github.com/adolli/prometheus/issues/4562
func (Matrix) TotalSamples ¶ added in v1.25.3
TotalSamples returns the total number of samples in the series within a matrix.
type Point ¶ added in v1.25.3
Point represents a single data point for a given timestamp.
func (Point) MarshalJSON ¶ added in v1.25.3
MarshalJSON implements json.Marshaler.
type Query ¶
type Query interface { // Exec processes the query. Can only be called once. Exec(ctx context.Context) *Result // Close recovers memory used by the query result. Close() // Statement returns the parsed statement of the query. Statement() parser.Statement // Stats returns statistics about the lifetime of the query. Stats() *stats.QueryTimers // Cancel signals that a running query execution should be aborted. Cancel() }
A Query is derived from an a raw query string and can be run against an engine it is associated with.
type QueryLogger ¶ added in v1.25.3
QueryLogger is an interface that can be used to log all the queries logged by the engine.
type QueryOrigin ¶ added in v1.25.3
type QueryOrigin struct{}
type Result ¶
Result holds the resulting value of an execution or an error if any occurred.
func (*Result) Matrix ¶
Matrix returns a Matrix. An error is returned if the result was an error or the result value is not a Matrix.
type Sample ¶ added in v1.25.3
Sample is a single sample belonging to a metric.
func (Sample) MarshalJSON ¶ added in v1.25.3
type Scalar ¶ added in v1.25.3
Scalar is a data point that's explicitly not associated with a metric.
func (Scalar) MarshalJSON ¶ added in v1.25.3
type StorageSeries ¶ added in v1.25.3
type StorageSeries struct {
// contains filtered or unexported fields
}
StorageSeries simulates promql.Series as storage.Series.
func NewStorageSeries ¶ added in v1.25.3
func NewStorageSeries(series Series) *StorageSeries
NewStorageSeries returns a StorageSeries from a Series.
func (*StorageSeries) Iterator ¶ added in v1.25.3
func (ss *StorageSeries) Iterator() chunkenc.Iterator
Iterator returns a new iterator of the data of the series.
func (*StorageSeries) Labels ¶ added in v1.25.3
func (ss *StorageSeries) Labels() labels.Labels
type String ¶ added in v1.25.3
String represents a string value.
func (String) MarshalJSON ¶ added in v1.25.3
type Test ¶
Test is a sequence of read and write commands that are run against a test storage.
func (*Test) QueryEngine ¶
QueryEngine returns the test's query engine.
type Vector ¶ added in v1.25.3
type Vector []Sample
Vector is basically only an alias for model.Samples, but the contract is that in a Vector, all Samples have the same timestamp.
func (Vector) ContainsSameLabelset ¶ added in v1.25.3
ContainsSameLabelset checks if a vector has samples with the same labelset Such a behavior is semantically undefined https://github.com/adolli/prometheus/issues/4562