Documentation ¶
Index ¶
- Constants
- Variables
- func EvaluatorUnsupportedType(expr syntax.Expr, ev Evaluator) error
- func Match(xs []string) ([][]*labels.Matcher, error)
- func PopulateMatrixFromScalar(data promql.Scalar, params Params) promql.Matrix
- func QueryType(query string) (string, error)
- func RecordMetrics(ctx context.Context, log log.Logger, p Params, status string, ...)
- func ResultIterator(res logqlmodel.Result, params Params) (iter.EntryIterator, error)
- type ConcatLogSelectorExpr
- type ConcatSampleExpr
- type DefaultEvaluator
- type DownstreamEngine
- type DownstreamEvaluator
- func (ev DownstreamEvaluator) Downstream(ctx context.Context, queries []DownstreamQuery) ([]logqlmodel.Result, error)
- func (ev *DownstreamEvaluator) Iterator(ctx context.Context, expr syntax.LogSelectorExpr, params Params) (iter.EntryIterator, error)
- func (ev *DownstreamEvaluator) StepEvaluator(ctx context.Context, nextEv SampleEvaluator, expr syntax.SampleExpr, ...) (StepEvaluator, error)
- type DownstreamLogSelectorExpr
- type DownstreamQuery
- type DownstreamSampleExpr
- type Downstreamable
- type Downstreamer
- type Engine
- type EngineOpts
- type EntryEvaluator
- type Evaluator
- type Limits
- type LiteralParams
- func (p LiteralParams) Copy() LiteralParams
- func (p LiteralParams) Direction() logproto.Direction
- func (p LiteralParams) End() time.Time
- func (p LiteralParams) Interval() time.Duration
- func (p LiteralParams) Limit() uint32
- func (p LiteralParams) Query() string
- func (p LiteralParams) Shards() []string
- func (p LiteralParams) Start() time.Time
- func (p LiteralParams) Step() time.Duration
- type MatrixStepper
- type MockDownstreamer
- type MockQuerier
- type Params
- type Querier
- type Query
- type QueryParams
- type QueryRangeType
- type RangeVectorAggregator
- type RangeVectorIterator
- type SampleEvaluator
- type SampleEvaluatorFunc
- type SelectLogParams
- type SelectSampleParams
- type ShardMapper
- type ShardingMetrics
- type Shards
- type StepEvaluator
Constants ¶
const ( QueryTypeMetric = "metric" QueryTypeFilter = "filter" QueryTypeLimited = "limited" )
const ( StreamsKey = "streams" MetricsKey = "metrics" SuccessKey = "success" FailureKey = "failure" NoopKey = "noop" )
keys used in metrics
Variables ¶
var (
NoLimits = &fakeLimits{maxSeries: math.MaxInt32}
)
Functions ¶
func EvaluatorUnsupportedType ¶
EvaluatorUnsupportedType is a helper for signaling that an evaluator does not support an Expr type
func RecordMetrics ¶
func RecordMetrics(ctx context.Context, log log.Logger, p Params, status string, stats logql_stats.Result, result promql_parser.Value)
func ResultIterator ¶
func ResultIterator(res logqlmodel.Result, params Params) (iter.EntryIterator, error)
ResultIterator coerces a downstream streams result into an iter.EntryIterator
Types ¶
type ConcatLogSelectorExpr ¶
type ConcatLogSelectorExpr struct { DownstreamLogSelectorExpr // contains filtered or unexported fields }
ConcatLogSelectorExpr is an expr for concatenating multiple LogSelectorExpr
func (ConcatLogSelectorExpr) String ¶
func (c ConcatLogSelectorExpr) String() string
type ConcatSampleExpr ¶
type ConcatSampleExpr struct { DownstreamSampleExpr // contains filtered or unexported fields }
ConcatSampleExpr is an expr for concatenating multiple SampleExpr Contract: The embedded SampleExprs within a linked list of ConcatSampleExprs must be of the same structure. This makes special implementations of SampleExpr.Associative() unnecessary.
func (ConcatSampleExpr) String ¶
func (c ConcatSampleExpr) String() string
func (ConcatSampleExpr) Walk ¶
func (c ConcatSampleExpr) Walk(f syntax.WalkFn)
type DefaultEvaluator ¶
type DefaultEvaluator struct {
// contains filtered or unexported fields
}
func NewDefaultEvaluator ¶
func NewDefaultEvaluator(querier Querier, maxLookBackPeriod time.Duration) *DefaultEvaluator
NewDefaultEvaluator constructs a DefaultEvaluator
func (*DefaultEvaluator) Iterator ¶
func (ev *DefaultEvaluator) Iterator(ctx context.Context, expr syntax.LogSelectorExpr, q Params) (iter.EntryIterator, error)
func (*DefaultEvaluator) StepEvaluator ¶
func (ev *DefaultEvaluator) StepEvaluator( ctx context.Context, nextEv SampleEvaluator, expr syntax.SampleExpr, q Params, ) (StepEvaluator, error)
type DownstreamEngine ¶
type DownstreamEngine struct {
// contains filtered or unexported fields
}
DownstreamEngine is an Engine implementation that can split queries into more parallelizable forms via querying the underlying backend shards individually and re-aggregating them.
func NewDownstreamEngine ¶
func NewDownstreamEngine(opts EngineOpts, downstreamable Downstreamable, metrics *ShardingMetrics, limits Limits, logger log.Logger) *DownstreamEngine
NewDownstreamEngine constructs a *DownstreamEngine
type DownstreamEvaluator ¶
type DownstreamEvaluator struct { Downstreamer // contains filtered or unexported fields }
DownstreamEvaluator is an evaluator which handles shard aware AST nodes
func NewDownstreamEvaluator ¶
func NewDownstreamEvaluator(downstreamer Downstreamer) *DownstreamEvaluator
func (DownstreamEvaluator) Downstream ¶
func (ev DownstreamEvaluator) Downstream(ctx context.Context, queries []DownstreamQuery) ([]logqlmodel.Result, error)
Downstream runs queries and collects stats from the embedded Downstreamer
func (*DownstreamEvaluator) Iterator ¶
func (ev *DownstreamEvaluator) Iterator( ctx context.Context, expr syntax.LogSelectorExpr, params Params, ) (iter.EntryIterator, error)
Iterator returns the iter.EntryIterator for a given LogSelectorExpr
func (*DownstreamEvaluator) StepEvaluator ¶
func (ev *DownstreamEvaluator) StepEvaluator( ctx context.Context, nextEv SampleEvaluator, expr syntax.SampleExpr, params Params, ) (StepEvaluator, error)
StepEvaluator returns a StepEvaluator for a given SampleExpr
type DownstreamLogSelectorExpr ¶
type DownstreamLogSelectorExpr struct { syntax.LogSelectorExpr // contains filtered or unexported fields }
DownstreamLogSelectorExpr is a LogSelectorExpr which signals downstream computation
func (DownstreamLogSelectorExpr) String ¶
func (d DownstreamLogSelectorExpr) String() string
type DownstreamSampleExpr ¶
type DownstreamSampleExpr struct { syntax.SampleExpr // contains filtered or unexported fields }
DownstreamSampleExpr is a SampleExpr which signals downstream computation
func (DownstreamSampleExpr) String ¶
func (d DownstreamSampleExpr) String() string
func (DownstreamSampleExpr) Walk ¶
func (d DownstreamSampleExpr) Walk(f syntax.WalkFn)
type Downstreamable ¶
type Downstreamable interface {
Downstreamer() Downstreamer
}
type Downstreamer ¶
type Downstreamer interface {
Downstream(context.Context, []DownstreamQuery) ([]logqlmodel.Result, error)
}
Downstreamer is an interface for deferring responsibility for query execution. It is decoupled from but consumed by a downStreamEvaluator to dispatch ASTs.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the LogQL engine.
type EngineOpts ¶
type EngineOpts struct { // Timeout for queries execution Timeout time.Duration `yaml:"timeout"` // MaxLookBackPeriod is the maximum amount of time to look back for log lines. // only used for instant log queries. MaxLookBackPeriod time.Duration `yaml:"max_look_back_period"` }
EngineOpts is the list of options to use with the LogQL query engine.
func (*EngineOpts) RegisterFlagsWithPrefix ¶
func (opts *EngineOpts) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)
type EntryEvaluator ¶
type EntryEvaluator interface { // Iterator returns the iter.EntryIterator for a given LogSelectorExpr Iterator(context.Context, syntax.LogSelectorExpr, Params) (iter.EntryIterator, error) }
type Evaluator ¶
type Evaluator interface { SampleEvaluator EntryEvaluator }
Evaluator is an interface for iterating over data at different nodes in the AST
type LiteralParams ¶
type LiteralParams struct {
// contains filtered or unexported fields
}
LiteralParams impls Params
func NewLiteralParams ¶
func (LiteralParams) Copy ¶
func (p LiteralParams) Copy() LiteralParams
func (LiteralParams) Direction ¶
func (p LiteralParams) Direction() logproto.Direction
Direction impls Params
func (LiteralParams) Interval ¶
func (p LiteralParams) Interval() time.Duration
Interval impls Params
type MatrixStepper ¶
type MatrixStepper struct {
// contains filtered or unexported fields
}
MatrixStepper exposes a promql.Matrix as a StepEvaluator. Ensure that the resulting StepEvaluator maintains the same shape that the parameters expect. For example, it's possible that a downstream query returns matches no log streams and thus returns an empty matrix. However, we still need to ensure that it can be merged effectively with another leg that may match series. Therefore, we determine our steps from the parameters and not the underlying Matrix.
func NewMatrixStepper ¶
func (*MatrixStepper) Close ¶
func (m *MatrixStepper) Close() error
func (*MatrixStepper) Error ¶
func (m *MatrixStepper) Error() error
type MockDownstreamer ¶
type MockDownstreamer struct {
*Engine
}
func (MockDownstreamer) Downstream ¶
func (m MockDownstreamer) Downstream(ctx context.Context, queries []DownstreamQuery) ([]logqlmodel.Result, error)
func (MockDownstreamer) Downstreamer ¶
func (m MockDownstreamer) Downstreamer() Downstreamer
type MockQuerier ¶
type MockQuerier struct {
// contains filtered or unexported fields
}
Shard aware mock querier
func NewMockQuerier ¶
func NewMockQuerier(shards int, streams []logproto.Stream) MockQuerier
func (MockQuerier) SelectLogs ¶
func (q MockQuerier) SelectLogs(ctx context.Context, req SelectLogParams) (iter.EntryIterator, error)
func (MockQuerier) SelectSamples ¶
func (q MockQuerier) SelectSamples(ctx context.Context, req SelectSampleParams) (iter.SampleIterator, error)
type Params ¶
type Params interface { Query() string Start() time.Time End() time.Time Step() time.Duration Interval() time.Duration Limit() uint32 Direction() logproto.Direction Shards() []string }
Params details the parameters associated with a loki request
type Querier ¶
type Querier interface { SelectLogs(context.Context, SelectLogParams) (iter.EntryIterator, error) SelectSamples(context.Context, SelectSampleParams) (iter.SampleIterator, error) }
Querier allows a LogQL expression to fetch an EntryIterator for a set of matchers and filters
type Query ¶
type Query interface { // Exec processes the query. Exec(ctx context.Context) (logqlmodel.Result, error) }
Query is a LogQL query to be executed.
type QueryParams ¶
type QueryRangeType ¶
type QueryRangeType string
var ( InstantType QueryRangeType = "instant" RangeType QueryRangeType = "range" )
func GetRangeType ¶
func GetRangeType(q Params) QueryRangeType
GetRangeType returns whether a query is an instant query or range query
type RangeVectorAggregator ¶
RangeVectorAggregator aggregates samples for a given range of samples. It receives the current milliseconds timestamp and the list of point within the range.
type RangeVectorIterator ¶
type RangeVectorIterator interface { Next() bool At(aggregator RangeVectorAggregator) (int64, promql.Vector) Close() error Error() error }
RangeVectorIterator iterates through a range of samples. To fetch the current vector use `At` with a `RangeVectorAggregator`.
type SampleEvaluator ¶
type SampleEvaluator interface { // StepEvaluator returns a StepEvaluator for a given SampleExpr. It's explicitly passed another StepEvaluator// in order to enable arbitrary computation of embedded expressions. This allows more modular & extensible // StepEvaluator implementations which can be composed. StepEvaluator(ctx context.Context, nextEvaluator SampleEvaluator, expr syntax.SampleExpr, p Params) (StepEvaluator, error) }
type SampleEvaluatorFunc ¶
type SampleEvaluatorFunc func(ctx context.Context, nextEvaluator SampleEvaluator, expr syntax.SampleExpr, p Params) (StepEvaluator, error)
func (SampleEvaluatorFunc) StepEvaluator ¶
func (s SampleEvaluatorFunc) StepEvaluator(ctx context.Context, nextEvaluator SampleEvaluator, expr syntax.SampleExpr, p Params) (StepEvaluator, error)
type SelectLogParams ¶
type SelectLogParams struct {
*logproto.QueryRequest
}
SelectParams specifies parameters passed to data selections.
func (SelectLogParams) LogSelector ¶
func (s SelectLogParams) LogSelector() (syntax.LogSelectorExpr, error)
LogSelector returns the LogSelectorExpr from the SelectParams. The `LogSelectorExpr` can then returns all matchers and filters to use for that request.
func (SelectLogParams) String ¶
func (s SelectLogParams) String() string
type SelectSampleParams ¶
type SelectSampleParams struct {
*logproto.SampleQueryRequest
}
func (SelectSampleParams) Expr ¶
func (s SelectSampleParams) Expr() (syntax.SampleExpr, error)
Expr returns the SampleExpr from the SelectSampleParams. The `LogSelectorExpr` can then returns all matchers and filters to use for that request.
func (SelectSampleParams) LogSelector ¶
func (s SelectSampleParams) LogSelector() (syntax.LogSelectorExpr, error)
LogSelector returns the LogSelectorExpr from the SelectParams. The `LogSelectorExpr` can then returns all matchers and filters to use for that request.
type ShardMapper ¶
type ShardMapper struct {
// contains filtered or unexported fields
}
func NewShardMapper ¶
func NewShardMapper(shards int, metrics *ShardingMetrics) (ShardMapper, error)
type ShardingMetrics ¶
type ShardingMetrics struct { Shards *prometheus.CounterVec // sharded queries total, partitioned by (streams/metric) ShardFactor prometheus.Histogram // per request shard factor // contains filtered or unexported fields }
ShardingMetrics is the metrics wrapper used in shard mapping
func NewShardingMetrics ¶
func NewShardingMetrics(registerer prometheus.Registerer) *ShardingMetrics
type Shards ¶
type Shards []astmapper.ShardAnnotation
func ParseShards ¶
ParseShards parses a list of string encoded shards
type StepEvaluator ¶
type StepEvaluator interface { // while Next returns a promql.Value, the only acceptable types are Scalar and Vector. Next() (ok bool, ts int64, vec promql.Vector) // Close all resources used. Close() error // Reports any error Error() error }
StepEvaluator evaluate a single step of a query.
func ConcatEvaluator ¶
func ConcatEvaluator(evaluators []StepEvaluator) (StepEvaluator, error)
ConcatEvaluator joins multiple StepEvaluators. Contract: They must be of identical start, end, and step values.
func ResultStepEvaluator ¶
func ResultStepEvaluator(res logqlmodel.Result, params Params) (StepEvaluator, error)
ResultStepEvaluator coerces a downstream vector or matrix into a StepEvaluator