logqlmetric

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package logqlmetric provides metric queries implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadStepResponse

func ReadStepResponse(iter iterators.Iterator[Step], instant bool) (s lokiapi.QueryResponseData, _ error)

ReadStepResponse reads aggregation result into API structure.

Types

type AggregatedLabels

type AggregatedLabels interface {
	// By returns new set of labels containing only given list of labels.
	By(...logql.Label) AggregatedLabels
	// Without returns new set of labels without given list of labels.
	Without(...logql.Label) AggregatedLabels
	// Key computes grouping key from set of labels.
	Key() GroupingKey
	// Replace replaces labels using given regexp.
	Replace(dstLabel, replacement, srcLabel string, re *regexp.Regexp) AggregatedLabels

	// AsLokiAPI returns API structure for label set.
	AsLokiAPI() lokiapi.LabelSet
}

AggregatedLabels is a set of labels.

type Aggregator

type Aggregator interface {
	Reset()
	Apply(v float64)
	Result() float64
}

Aggregator is a stateful streaming aggregator.

type AvgAggregator

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

AvgAggregator implements moving cumulative average aggregation.

func (*AvgAggregator) Apply

func (a *AvgAggregator) Apply(v float64)

Apply implements Aggregator.

func (*AvgAggregator) Reset

func (a *AvgAggregator) Reset()

Reset implements Aggregator.

func (*AvgAggregator) Result

func (a *AvgAggregator) Result() float64

Result implements Aggregator.

type AvgOverTime

type AvgOverTime = batchApplier[AvgAggregator, *AvgAggregator]

AvgOverTime implements `avg_over_time` aggregation.

type BatchAggregator

type BatchAggregator interface {
	Aggregate(points []FPoint) float64
}

BatchAggregator is stateless batch aggregator.

type BytesRate

type BytesRate = Rate[SumOverTime]

BytesRate implements `bytes_rate` aggregation.

type CountAggregator

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

CountAggregator implements counting aggregation.

func (*CountAggregator) Apply

func (a *CountAggregator) Apply(float64)

Apply implements Aggregator.

func (*CountAggregator) Reset

func (a *CountAggregator) Reset()

Reset implements Aggregator.

func (*CountAggregator) Result

func (a *CountAggregator) Result() float64

Result implements Aggregator.

type CountOverTime

type CountOverTime struct{}

CountOverTime implements `count_over_time` aggregation.

func (CountOverTime) Aggregate

func (CountOverTime) Aggregate(points []FPoint) float64

Aggregate implements BatchAggregator.

type EvalParams

type EvalParams struct {
	Start, End time.Time
	Step       time.Duration
}

EvalParams is a query evaluation params.

type FPoint

type FPoint struct {
	Timestamp otelstorage.Timestamp
	Value     float64
}

FPoint is a metric point.

type FirstOverTime

type FirstOverTime struct{}

FirstOverTime implements `first_over_time` aggregation.

func (FirstOverTime) Aggregate

func (FirstOverTime) Aggregate(points []FPoint) float64

Aggregate implements BatchAggregator.

type GroupingKey

type GroupingKey = uint64

GroupingKey is a key to group metrics by label.

type LastOverTime

type LastOverTime struct{}

LastOverTime implements `last_over_time` aggregation.

func (LastOverTime) Aggregate

func (LastOverTime) Aggregate(points []FPoint) (last float64)

Aggregate implements BatchAggregator.

type MaxAggregator

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

MaxAggregator implements max aggregation.

func (*MaxAggregator) Apply

func (a *MaxAggregator) Apply(v float64)

Apply implements Aggregator.

func (*MaxAggregator) Reset

func (a *MaxAggregator) Reset()

Reset implements Aggregator.

func (*MaxAggregator) Result

func (a *MaxAggregator) Result() float64

Result implements Aggregator.

type MaxOverTime

type MaxOverTime = batchApplier[MaxAggregator, *MaxAggregator]

MaxOverTime implements `max_over_time` aggregation.

type MinAggregator

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

MinAggregator implements min aggregation.

func (*MinAggregator) Apply

func (a *MinAggregator) Apply(v float64)

Apply implements Aggregator.

func (*MinAggregator) Reset

func (a *MinAggregator) Reset()

Reset implements Aggregator.

func (*MinAggregator) Result

func (a *MinAggregator) Result() float64

Result implements Aggregator.

type MinOverTime

type MinOverTime = batchApplier[MinAggregator, *MinAggregator]

MinOverTime implements `min_over_time` aggregation.

type QuantileOverTime

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

QuantileOverTime implements `quantile_over_time` aggregation.

func (QuantileOverTime) Aggregate

func (a QuantileOverTime) Aggregate(points []FPoint) float64

Aggregate implements BatchAggregator.

type Rate

type Rate[A BatchAggregator] struct {
	// contains filtered or unexported fields
}

Rate implements `rate` aggregation.

func (Rate[A]) Aggregate

func (a Rate[A]) Aggregate(points []FPoint) float64

Aggregate implements BatchAggregator.

type Sample

type Sample struct {
	Data float64
	Set  AggregatedLabels
}

Sample is a metric sample extracted from logs.

func (Sample) Greater

func (a Sample) Greater(b Sample) bool

Greater compares two samples by value.

func (Sample) Less

func (a Sample) Less(b Sample) bool

Less compares two samples by value.

type SampleOp

type SampleOp = func(left, right Sample) (Sample, bool)

SampleOp is a binary operation for two samples.

type SampleSelector

type SampleSelector = func(expr *logql.RangeAggregationExpr, start, end time.Time) (iterators.Iterator[SampledEntry], error)

SampleSelector creates new sampled entry iterator.

type SampledEntry

type SampledEntry struct {
	Sample    float64
	Timestamp otelstorage.Timestamp
	Set       AggregatedLabels
}

SampledEntry is a sampled log entry.

type Series

type Series struct {
	Data []FPoint
	Set  AggregatedLabels
}

Series is a grouped set of metric points.

type StddevAggregator

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

StddevAggregator implements standard deviation aggregation.

func (*StddevAggregator) Apply

func (a *StddevAggregator) Apply(v float64)

Apply implements Aggregator.

func (*StddevAggregator) Reset

func (a *StddevAggregator) Reset()

Reset implements Aggregator.

func (*StddevAggregator) Result

func (a *StddevAggregator) Result() float64

Result implements Aggregator.

type StddevOverTime

type StddevOverTime = batchApplier[StddevAggregator, *StddevAggregator]

StddevOverTime implements `stddev_over_time` aggregation.

type StdvarAggregator

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

StdvarAggregator implements standard variance aggregation.

func (*StdvarAggregator) Apply

func (a *StdvarAggregator) Apply(v float64)

Apply implements Aggregator.

func (*StdvarAggregator) Reset

func (a *StdvarAggregator) Reset()

Reset implements Aggregator.

func (*StdvarAggregator) Result

func (a *StdvarAggregator) Result() float64

Result implements Aggregator.

type StdvarOverTime

type StdvarOverTime = batchApplier[StdvarAggregator, *StdvarAggregator]

StdvarOverTime implements `stdvar_over_time` aggregation.

type Step

type Step struct {
	Timestamp otelstorage.Timestamp
	Samples   []Sample
}

Step represents a one query range step i

type StepIterator

type StepIterator = iterators.Iterator[Step]

StepIterator is a one query range step iterator.

func BinOp

func BinOp(
	left, right StepIterator,
	expr *logql.BinOpExpr,
) (StepIterator, error)

BinOp returns new step iterator performing binary operation between two iterators.

func Build

func Build(expr logql.MetricExpr, sel SampleSelector, params EvalParams) (StepIterator, error)

Build builds new step iterator.

func LabelReplace

func LabelReplace(iter StepIterator, expr *logql.LabelReplaceExpr) (StepIterator, error)

LabelReplace returns new step iterator performing label replacement.

func LiteralBinOp

func LiteralBinOp(
	iter StepIterator,
	expr *logql.BinOpExpr,
	value float64,
	left bool,
) (StepIterator, error)

LiteralBinOp returns new step iterator performing binary operation with literal.

func RangeAggregation

func RangeAggregation(
	iter iterators.Iterator[SampledEntry],
	expr *logql.RangeAggregationExpr,
	start, end time.Time,
	step time.Duration,
) (StepIterator, error)

RangeAggregation creates new range aggregation step iterator.

func Vector

func Vector(
	expr *logql.VectorExpr,
	start, end time.Time,
	step time.Duration,
) StepIterator

Vector creates new vector function step iterator.

func VectorAggregation

func VectorAggregation(
	iter iterators.Iterator[Step],
	expr *logql.VectorAggregationExpr,
) (StepIterator, error)

VectorAggregation creates new Vector aggregation step iterator.

type SumAggregator

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

SumAggregator implements moving summing aggregation.

func (*SumAggregator) Apply

func (a *SumAggregator) Apply(v float64)

Apply implements Aggregator.

func (*SumAggregator) Reset

func (a *SumAggregator) Reset()

Reset implements Aggregator.

func (*SumAggregator) Result

func (a *SumAggregator) Result() float64

Result implements Aggregator.

type SumOverTime

type SumOverTime = batchApplier[SumAggregator, *SumAggregator]

SumOverTime implements `sum_over_time` aggregation.

type UnsupportedError

type UnsupportedError struct {
	Msg string
}

UnsupportedError is an error that reports unsupported expressions.

func (*UnsupportedError) Error

func (e *UnsupportedError) Error() string

Error implements error.

Jump to

Keyboard shortcuts

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