Documentation ¶
Index ¶
- Variables
- func HistogramAvg(seriesData types.InstantVectorSeriesData, _ []types.ScalarData, ...) (types.InstantVectorSeriesData, error)
- func HistogramCount(seriesData types.InstantVectorSeriesData, _ []types.ScalarData, ...) (types.InstantVectorSeriesData, error)
- func HistogramFraction(seriesData types.InstantVectorSeriesData, scalarArgsData []types.ScalarData, ...) (types.InstantVectorSeriesData, error)
- func HistogramSum(seriesData types.InstantVectorSeriesData, _ []types.ScalarData, ...) (types.InstantVectorSeriesData, error)
- func NativeHistogramErrorToAnnotation(err error, emitAnnotation types.EmitAnnotationFunc) error
- func PassthroughData(seriesData types.InstantVectorSeriesData, _ []types.ScalarData, ...) (types.InstantVectorSeriesData, error)
- type FunctionOverInstantVector
- func (m *FunctionOverInstantVector) Close()
- func (m *FunctionOverInstantVector) ExpressionPosition() posrange.PositionRange
- func (m *FunctionOverInstantVector) NextSeries(ctx context.Context) (types.InstantVectorSeriesData, error)
- func (m *FunctionOverInstantVector) SeriesMetadata(ctx context.Context) ([]types.SeriesMetadata, error)
- type FunctionOverInstantVectorDefinition
- type FunctionOverRangeVector
- func (m *FunctionOverRangeVector) Close()
- func (m *FunctionOverRangeVector) ExpressionPosition() posrange.PositionRange
- func (m *FunctionOverRangeVector) NextSeries(ctx context.Context) (types.InstantVectorSeriesData, error)
- func (m *FunctionOverRangeVector) SeriesMetadata(ctx context.Context) ([]types.SeriesMetadata, error)
- type FunctionOverRangeVectorDefinition
- type HistogramQuantileFunction
- func (h *HistogramQuantileFunction) Close()
- func (h *HistogramQuantileFunction) ExpressionPosition() posrange.PositionRange
- func (h *HistogramQuantileFunction) NextSeries(ctx context.Context) (types.InstantVectorSeriesData, error)
- func (h *HistogramQuantileFunction) SeriesMetadata(ctx context.Context) ([]types.SeriesMetadata, error)
- type InstantVectorSeriesFunction
- type RangeVectorSeriesValidationFunction
- type RangeVectorSeriesValidationFunctionFactory
- type RangeVectorStepFunction
- type SeriesMetadataFunction
- type SeriesMetadataFunctionDefinition
Constants ¶
This section is empty.
Variables ¶
var Abs = FloatTransformationDropHistogramsFunc(math.Abs)
var Acos = FloatTransformationDropHistogramsFunc(math.Acos)
var Acosh = FloatTransformationDropHistogramsFunc(math.Acosh)
var Asin = FloatTransformationDropHistogramsFunc(math.Asin)
var Asinh = FloatTransformationDropHistogramsFunc(math.Asinh)
var Atan = FloatTransformationDropHistogramsFunc(math.Atan)
var Atanh = FloatTransformationDropHistogramsFunc(math.Atanh)
var AvgOverTime = FunctionOverRangeVectorDefinition{ SeriesMetadataFunction: DropSeriesName, StepFunc: avgOverTime, NeedsSeriesNamesForAnnotations: true, }
var Ceil = FloatTransformationDropHistogramsFunc(math.Ceil)
var Changes = FunctionOverRangeVectorDefinition{ SeriesMetadataFunction: DropSeriesName, StepFunc: resetsChanges(false), }
var Cos = FloatTransformationDropHistogramsFunc(math.Cos)
var Cosh = FloatTransformationDropHistogramsFunc(math.Cosh)
var CountOverTime = FunctionOverRangeVectorDefinition{ SeriesMetadataFunction: DropSeriesName, StepFunc: countOverTime, }
var Deg = FloatTransformationDropHistogramsFunc(func(f float64) float64 { return f * 180 / math.Pi })
var Deriv = FunctionOverRangeVectorDefinition{ SeriesMetadataFunction: DropSeriesName, StepFunc: deriv, }
var DropSeriesName = SeriesMetadataFunctionDefinition{ Func: func(seriesMetadata []types.SeriesMetadata, _ *limiting.MemoryConsumptionTracker) ([]types.SeriesMetadata, error) { for i := range seriesMetadata { seriesMetadata[i].Labels = seriesMetadata[i].Labels.DropMetricName() } return seriesMetadata, nil }, NeedsSeriesDeduplication: true, }
DropSeriesName is a series metadata function that removes the __name__ label from all series.
var Exp = FloatTransformationDropHistogramsFunc(math.Exp)
var Floor = FloatTransformationDropHistogramsFunc(math.Floor)
var Increase = FunctionOverRangeVectorDefinition{ StepFunc: rate(false), SeriesValidationFuncFactory: rateSeriesValidator, SeriesMetadataFunction: DropSeriesName, NeedsSeriesNamesForAnnotations: true, }
var LastOverTime = FunctionOverRangeVectorDefinition{
StepFunc: lastOverTime,
}
var Log10 = FloatTransformationDropHistogramsFunc(math.Log10)
var Log2 = FloatTransformationDropHistogramsFunc(math.Log2)
var MaxOverTime = FunctionOverRangeVectorDefinition{ SeriesMetadataFunction: DropSeriesName, StepFunc: maxOverTime, }
var MinOverTime = FunctionOverRangeVectorDefinition{ SeriesMetadataFunction: DropSeriesName, StepFunc: minOverTime, }
var PresentOverTime = FunctionOverRangeVectorDefinition{ SeriesMetadataFunction: DropSeriesName, StepFunc: presentOverTime, }
var Rad = FloatTransformationDropHistogramsFunc(func(f float64) float64 { return f * math.Pi / 180 })
var Rate = FunctionOverRangeVectorDefinition{ StepFunc: rate(true), SeriesValidationFuncFactory: rateSeriesValidator, SeriesMetadataFunction: DropSeriesName, NeedsSeriesNamesForAnnotations: true, }
var Resets = FunctionOverRangeVectorDefinition{ SeriesMetadataFunction: DropSeriesName, StepFunc: resetsChanges(true), }
var Sgn = FloatTransformationDropHistogramsFunc(func(f float64) float64 {
if f < 0 {
return -1
}
if f > 0 {
return 1
}
return f
})
var Sin = FloatTransformationDropHistogramsFunc(math.Sin)
var Sinh = FloatTransformationDropHistogramsFunc(math.Sinh)
var Sqrt = FloatTransformationDropHistogramsFunc(math.Sqrt)
var SumOverTime = FunctionOverRangeVectorDefinition{ SeriesMetadataFunction: DropSeriesName, StepFunc: sumOverTime, NeedsSeriesNamesForAnnotations: true, }
var Tan = FloatTransformationDropHistogramsFunc(math.Tan)
var Tanh = FloatTransformationDropHistogramsFunc(math.Tanh)
Functions ¶
func HistogramAvg ¶
func HistogramAvg(seriesData types.InstantVectorSeriesData, _ []types.ScalarData, _ types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, error)
func HistogramCount ¶
func HistogramCount(seriesData types.InstantVectorSeriesData, _ []types.ScalarData, _ types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, error)
func HistogramFraction ¶
func HistogramFraction(seriesData types.InstantVectorSeriesData, scalarArgsData []types.ScalarData, timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, error)
func HistogramSum ¶
func HistogramSum(seriesData types.InstantVectorSeriesData, _ []types.ScalarData, _ types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, error)
func NativeHistogramErrorToAnnotation ¶
func NativeHistogramErrorToAnnotation(err error, emitAnnotation types.EmitAnnotationFunc) error
func PassthroughData ¶
func PassthroughData(seriesData types.InstantVectorSeriesData, _ []types.ScalarData, _ types.QueryTimeRange, _ *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, error)
Types ¶
type FunctionOverInstantVector ¶
type FunctionOverInstantVector struct { // At the moment no instant-vector promql function takes more than one instant-vector // as an argument. We can assume this will always be the Inner operator and therefore // what we use for the SeriesMetadata. Inner types.InstantVectorOperator // Any scalar arguments will be read once and passed to Func.SeriesDataFunc. ScalarArgs []types.ScalarOperator MemoryConsumptionTracker *limiting.MemoryConsumptionTracker Func FunctionOverInstantVectorDefinition // contains filtered or unexported fields }
FunctionOverInstantVector performs a function over each series in an instant vector.
func NewFunctionOverInstantVector ¶
func NewFunctionOverInstantVector( inner types.InstantVectorOperator, scalarArgs []types.ScalarOperator, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, f FunctionOverInstantVectorDefinition, expressionPosition posrange.PositionRange, timeRange types.QueryTimeRange, ) *FunctionOverInstantVector
func (*FunctionOverInstantVector) Close ¶
func (m *FunctionOverInstantVector) Close()
func (*FunctionOverInstantVector) ExpressionPosition ¶
func (m *FunctionOverInstantVector) ExpressionPosition() posrange.PositionRange
func (*FunctionOverInstantVector) NextSeries ¶
func (m *FunctionOverInstantVector) NextSeries(ctx context.Context) (types.InstantVectorSeriesData, error)
func (*FunctionOverInstantVector) SeriesMetadata ¶
func (m *FunctionOverInstantVector) SeriesMetadata(ctx context.Context) ([]types.SeriesMetadata, error)
type FunctionOverInstantVectorDefinition ¶
type FunctionOverInstantVectorDefinition struct { // SeriesDataFunc is the function that computes an output series for a single input series. SeriesDataFunc InstantVectorSeriesFunction // SeriesMetadataFunction is the function that computes the output series for this function based on the given input series. // // If SeriesMetadataFunction.Func is nil, the input series are used as-is. SeriesMetadataFunction SeriesMetadataFunctionDefinition }
type FunctionOverRangeVector ¶
type FunctionOverRangeVector struct { Inner types.RangeVectorOperator MemoryConsumptionTracker *limiting.MemoryConsumptionTracker Func FunctionOverRangeVectorDefinition Annotations *annotations.Annotations // contains filtered or unexported fields }
FunctionOverRangeVector performs a rate calculation over a range vector.
func NewFunctionOverRangeVector ¶
func NewFunctionOverRangeVector( inner types.RangeVectorOperator, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, f FunctionOverRangeVectorDefinition, annotations *annotations.Annotations, expressionPosition posrange.PositionRange, timeRange types.QueryTimeRange, ) *FunctionOverRangeVector
func (*FunctionOverRangeVector) Close ¶
func (m *FunctionOverRangeVector) Close()
func (*FunctionOverRangeVector) ExpressionPosition ¶
func (m *FunctionOverRangeVector) ExpressionPosition() posrange.PositionRange
func (*FunctionOverRangeVector) NextSeries ¶
func (m *FunctionOverRangeVector) NextSeries(ctx context.Context) (types.InstantVectorSeriesData, error)
func (*FunctionOverRangeVector) SeriesMetadata ¶
func (m *FunctionOverRangeVector) SeriesMetadata(ctx context.Context) ([]types.SeriesMetadata, error)
type FunctionOverRangeVectorDefinition ¶
type FunctionOverRangeVectorDefinition struct { // StepFunc is the function that computes an output sample for a single step. StepFunc RangeVectorStepFunction // SeriesValidationFuncFactory is the function that creates a validator for a complete series, emitting any annotations // for that series. // // A new validator instance is created for each instance of this range vector function (ie. a validator is not shared // between queries or between different invocations of the same range vector function in a single query). A single // instance of a range vector function can then implement optimisations such as skipping checks for repeated metric // names. // // SeriesValidationFuncFactory can be nil, in which case no validation is performed. SeriesValidationFuncFactory RangeVectorSeriesValidationFunctionFactory // SeriesMetadataFunction is the function that computes the output series for this function based on the given input series. // // If SeriesMetadataFunction.Func is nil, the input series are used as-is. SeriesMetadataFunction SeriesMetadataFunctionDefinition // NeedsSeriesNamesForAnnotations indicates that this function uses the names of input series when emitting annotations. NeedsSeriesNamesForAnnotations bool }
type HistogramQuantileFunction ¶
type HistogramQuantileFunction struct {
// contains filtered or unexported fields
}
HistogramQuantileFunction performs a function over each series in an instant vector, with special handling for classic and native histograms. At the moment, it only supports histogram_quantile
func NewHistogramQuantileFunction ¶
func NewHistogramQuantileFunction( phArg types.ScalarOperator, inner types.InstantVectorOperator, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, annotations *annotations.Annotations, expressionPosition posrange.PositionRange, timeRange types.QueryTimeRange, ) *HistogramQuantileFunction
func (*HistogramQuantileFunction) Close ¶
func (h *HistogramQuantileFunction) Close()
func (*HistogramQuantileFunction) ExpressionPosition ¶
func (h *HistogramQuantileFunction) ExpressionPosition() posrange.PositionRange
func (*HistogramQuantileFunction) NextSeries ¶
func (h *HistogramQuantileFunction) NextSeries(ctx context.Context) (types.InstantVectorSeriesData, error)
func (*HistogramQuantileFunction) SeriesMetadata ¶
func (h *HistogramQuantileFunction) SeriesMetadata(ctx context.Context) ([]types.SeriesMetadata, error)
type InstantVectorSeriesFunction ¶
type InstantVectorSeriesFunction func(seriesData types.InstantVectorSeriesData, scalarArgsData []types.ScalarData, timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, error)
InstantVectorSeriesFunction is a function that takes in an instant vector and produces an instant vector.
var Clamp InstantVectorSeriesFunction = func(seriesData types.InstantVectorSeriesData, scalarArgsData []types.ScalarData, timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, error) { outputIdx := 0 minArg := scalarArgsData[0] maxArg := scalarArgsData[1] for _, data := range seriesData.Floats { idx := timeRange.PointIndex(data.T) minVal := minArg.Samples[idx].F maxVal := maxArg.Samples[idx].F if maxVal < minVal { continue } seriesData.Floats[outputIdx].T = data.T seriesData.Floats[outputIdx].F = max(minVal, min(maxVal, data.F)) outputIdx++ } seriesData.Floats = seriesData.Floats[:outputIdx] types.HPointSlicePool.Put(seriesData.Histograms, memoryConsumptionTracker) seriesData.Histograms = nil return seriesData, nil }
var Round InstantVectorSeriesFunction = func(seriesData types.InstantVectorSeriesData, scalarArgsData []types.ScalarData, timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, error) { toNearest := scalarArgsData[0] for step, data := range seriesData.Floats { idx := timeRange.PointIndex(data.T) toNearestInverse := 1.0 / toNearest.Samples[idx].F seriesData.Floats[step].F = math.Floor(data.F*toNearestInverse+0.5) / toNearestInverse } types.HPointSlicePool.Put(seriesData.Histograms, memoryConsumptionTracker) seriesData.Histograms = nil return seriesData, nil }
round returns a number rounded to toNearest. Ties are solved by rounding up.
var UnaryNegation InstantVectorSeriesFunction = func(seriesData types.InstantVectorSeriesData, _ []types.ScalarData, _ types.QueryTimeRange, _ *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, error) { for i := range seriesData.Floats { seriesData.Floats[i].F = -seriesData.Floats[i].F } for i := range seriesData.Histograms { seriesData.Histograms[i].H.Mul(-1) } return seriesData, nil }
func ClampMinMaxFactory ¶
func ClampMinMaxFactory(isMin bool) InstantVectorSeriesFunction
func FloatTransformationDropHistogramsFunc ¶
func FloatTransformationDropHistogramsFunc(transform func(f float64) float64) InstantVectorSeriesFunction
func HistogramStdDevStdVar ¶
func HistogramStdDevStdVar(isStdDev bool) InstantVectorSeriesFunction
type RangeVectorSeriesValidationFunction ¶
type RangeVectorSeriesValidationFunction func(seriesData types.InstantVectorSeriesData, metricName string, emitAnnotation types.EmitAnnotationFunc)
RangeVectorSeriesValidationFunction is a function that is called after a series is completed for a function over a range vector.
type RangeVectorSeriesValidationFunctionFactory ¶
type RangeVectorSeriesValidationFunctionFactory func() RangeVectorSeriesValidationFunction
RangeVectorSeriesValidationFunctionFactory is a factory function that returns a RangeVectorSeriesValidationFunction
type RangeVectorStepFunction ¶
type RangeVectorStepFunction func( step *types.RangeVectorStepData, rangeSeconds float64, emitAnnotation types.EmitAnnotationFunc, ) (f float64, hasFloat bool, h *histogram.FloatHistogram, err error)
RangeVectorStepFunction is a function that operates on a range vector step.
floatBuffer and histogramBuffer will contain the values for the step range. They may also contain values outside of the step, so step.RangeEnd needs to be considered.
Parameters:
- step: the range vector step data to be processed.
- rangeSeconds: the duration of the range in seconds.
- floatBuffer: a ring buffer containing float values for the step range.
- histogramBuffer: a ring buffer containing histogram values for the step range.
- emitAnnotation: a callback function to emit an annotation for the current series.
Returns:
- hasFloat bool: a boolean indicating if a float value is present.
- f float64: the float value.
- h *histogram.FloatHistogram: nil if no histogram is present.
- err error.
type SeriesMetadataFunction ¶
type SeriesMetadataFunction func(seriesMetadata []types.SeriesMetadata, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) ([]types.SeriesMetadata, error)
SeriesMetadataFunction is a function to operate on the metadata across series.
func LabelReplaceFactory ¶
func LabelReplaceFactory(dstLabelOp, replacementOp, srcLabelOp, regexOp types.StringOperator) SeriesMetadataFunction
type SeriesMetadataFunctionDefinition ¶
type SeriesMetadataFunctionDefinition struct { // Func is the function that computes the output series for this function based on the given input series. // // If Func is nil, the input series are used as-is. Func SeriesMetadataFunction // NeedsSeriesDeduplication enables deduplication and merging of output series with the same labels. // // This should be set to true if Func modifies the input series labels in such a way that duplicates may be // present in the output series labels (eg. dropping a label). NeedsSeriesDeduplication bool }