Documentation
¶
Overview ¶
Code generated by goyacc -l -p expr -o pkg/logql/expr.y.go pkg/logql/expr.y. DO NOT EDIT.
Index ¶
- Constants
- Variables
- func EvaluatorUnsupportedType(expr Expr, ev Evaluator) error
- func HashForLabels(b []byte, ls labels.Labels, names ...string) (uint64, []byte)
- func HashLabels(b []byte, ls labels.Labels) (uint64, []byte)
- func HashWithoutLabels(b []byte, ls labels.Labels, names ...string) (uint64, []byte)
- func IsComparisonOperator(op string) bool
- func IsLogicalBinOp(op string) bool
- func ParseLabels(lbs string) (labels.Labels, error)
- func ParseMatchers(input string) ([]*labels.Matcher, error)
- func PopulateMatrixFromScalar(data promql.Scalar, params Params) promql.Matrix
- func QueryType(query string) (string, error)
- func RecordMetrics(ctx context.Context, p Params, status string, stats stats.Result, ...)
- func StringBuilderQuoteTo(b *strings.Builder, s string)
- type BinOpOptions
- type DefaultEvaluator
- type DropLabelsExpr
- type Engine
- type EngineOpts
- type EntryEvaluator
- type Evaluator
- type Expr
- type ExprNode
- type GroupBuilder
- 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 LogRange
- type LogSelectorExpr
- type MatchersBuilder
- type MatrixStepper
- type MultiStageExpr
- type Params
- type ParseError
- type Pipeline
- type PipelineBuilder
- type PipelineExpr
- type Querier
- type Query
- type QueryParams
- type QueryRangeType
- type RangeVectorAggregator
- type RangeVectorIterator
- type Result
- type SampleEvaluator
- type SampleEvaluatorFunc
- type SampleExpr
- type SampleExtractor
- type SelectLogParams
- type SelectSampleParams
- type StageExpr
- type StepEvaluator
- type Streams
Constants ¶
const ( // vector ops OpTypeSum = "sum" OpTypeAvg = "avg" OpTypeMax = "max" OpTypeMin = "min" OpTypeCount = "count" OpTypeStddev = "stddev" OpTypeStdvar = "stdvar" OpTypeBottomK = "bottomk" OpTypeTopK = "topk" // range vector ops OpRangeTypeCount = "count_over_time" OpRangeTypeRate = "rate" OpRangeTypeBytes = "bytes_over_time" OpRangeTypeBytesRate = "bytes_rate" OpRangeTypeAvg = "avg_over_time" OpRangeTypeSum = "sum_over_time" OpRangeTypeMin = "min_over_time" OpRangeTypeMax = "max_over_time" OpRangeTypeStdvar = "stdvar_over_time" OpRangeTypeStddev = "stddev_over_time" OpRangeTypeQuantile = "quantile_over_time" OpRangeTypeAbsent = "absent_over_time" OpRangeTypeFirst = "first_over_time" OpRangeTypeLast = "last_over_time" // binops - logical/set OpTypeOr = "or" OpTypeAnd = "and" OpTypeUnless = "unless" // binops - operations OpTypeAdd = "+" OpTypeSub = "-" OpTypeMul = "*" OpTypeDiv = "/" OpTypeMod = "%" OpTypePow = "^" // binops - comparison OpTypeCmpEQ = "==" OpTypeNEQ = "!=" OpTypeGT = ">" OpTypeGTE = ">=" OpTypeLT = "<" OpTypeLTE = "<=" // parsers OpParserTypeJSON = "json" OpParserTypeLogfmt = "logfmt" OpParserTypeRegexp = "regexp" OpParserTypePattern = "pattern" OpParserTypeUnpack = "unpack" OpFmtLine = "line_format" OpFmtLabel = "label_format" OpPipe = "|" OpUnwrap = "unwrap" // conversion Op OpConvBytes = "bytes" OpConvDuration = "duration" OpConvDurationSeconds = "duration_seconds" OpLabelReplace = "label_replace" // drop OpDrop = "drop" )
const ( QueryTypeMetric = "metric" QueryTypeFilter = "filter" QueryTypeLimited = "limited" )
const ABSENT_OVER_TIME = 57401
const ADD = 57416
const AND = 57408
const AVG = 57372
const AVG_OVER_TIME = 57391
const BOOL = 57382
const BOTTOMK = 57378
const BY = 57367
const BYTES = 57346
const BYTES_CONV = 57398
const BYTES_OVER_TIME = 57380
const BYTES_RATE = 57381
const CLOSE_BRACE = 57358
const CLOSE_BRACKET = 57360
const CLOSE_PARENTHESIS = 57366
const CMP_EQ = 57410
const COMMA = 57361
const COUNT = 57375
const COUNT_OVER_TIME = 57369
const DIV = 57419
const DOT = 57362
const DROP = 57404
const DURATION = 57350
const DURATION_CONV = 57399
const DURATION_SECONDS_CONV = 57400
const EQ = 57354
const FIRST_OVER_TIME = 57405
const GT = 57414
const GTE = 57415
const IDENTIFIER = 57347
const JSON = 57383
const LABELS = 57353
const LABEL_FMT = 57389
const LABEL_REPLACE = 57402
const LAST_OVER_TIME = 57406
const LINE_FMT = 57388
const LOGFMT = 57385
const LT = 57412
const LTE = 57413
const MATCHERS = 57352
const MAX = 57373
const MAX_OVER_TIME = 57394
const MIN = 57374
const MIN_OVER_TIME = 57393
const MOD = 57420
const MUL = 57418
const (
MetricName = "__name__"
)
const NEQ = 57411
const NRE = 57356
const NUMBER = 57349
const OPEN_BRACE = 57357
const OPEN_BRACKET = 57359
const OPEN_PARENTHESIS = 57365
const OR = 57407
const PATTERN = 57386
const PIPE = 57387
const PIPE_EXACT = 57364
const PIPE_MATCH = 57363
const POW = 57421
const QUANTILE_OVER_TIME = 57397
const RANGE = 57351
const RATE = 57370
const RE = 57355
const REGEXP = 57384
const STDDEV = 57376
const STDDEV_OVER_TIME = 57396
const STDVAR = 57377
const STDVAR_OVER_TIME = 57395
const STRING = 57348
const SUB = 57417
const SUM = 57371
const SUM_OVER_TIME = 57392
const TOPK = 57379
const UNLESS = 57409
const UNPACK = 57403
const UNWRAP = 57390
const ValueTypeStreams = "streams"
ValueTypeStreams promql.ValueType for log streams
const WITHOUT = 57368
Variables ¶
var ( ErrParse = errors.New("failed to parse the log query") ErrPipeline = errors.New("failed execute pipeline") ErrLimit = errors.New("limit reached while evaluating the query") )
Those errors are useful for comparing error returned by the engine. e.g. errors.Is(err,logql.ErrParse) let you know if this is a ast parsing error.
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 HashForLabels ¶
func HashWithoutLabels ¶
func IsComparisonOperator ¶
func IsLogicalBinOp ¶
IsLogicalBinOp tests whether an operation is a logical/set binary operation
func ParseLabels ¶
ParseLabels parses labels from a string using logql parser.
func ParseMatchers ¶
ParseMatchers parses a string and returns labels matchers, if the expression contains anything else it will return an error.
func RecordMetrics ¶
func StringBuilderQuoteTo ¶
Types ¶
type BinOpOptions ¶
type BinOpOptions struct {
ReturnBool bool
}
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 LogSelectorExpr, q Params, ) (iter.EntryIterator, error)
func (*DefaultEvaluator) StepEvaluator ¶
func (ev *DefaultEvaluator) StepEvaluator( ctx context.Context, nextEv SampleEvaluator, expr SampleExpr, q Params, ) (StepEvaluator, error)
type DropLabelsExpr ¶
type DropLabelsExpr struct {
// contains filtered or unexported fields
}
func (*DropLabelsExpr) String ¶
func (e *DropLabelsExpr) String() string
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the LogQL engine.
func NewEngine ¶
func NewEngine(opts EngineOpts, q Querier) *Engine
NewEngine creates a new 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"` RecordMetrics bool `yaml:"record_metrics"` LogStats bool `yaml:"log_stats"` }
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, 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 GroupBuilder ¶
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 LogSelectorExpr ¶
type LogSelectorExpr interface { Matchers() []*labels.Matcher PipelineExpr HasFilter() bool Expr }
LogSelectorExpr is a LogQL expression filtering and returning logs.
func AddFilterExpr ¶
func AddFilterExpr( expr LogSelectorExpr, ty labels.MatchType, match string, ) (LogSelectorExpr, error)
AddFilterExpr adds a filter expression to a logselector expression.
func ParseLogSelector ¶
func ParseLogSelector(input string) (LogSelectorExpr, error)
ParseLogSelector parses a log selector expression `{app="foo"} |= "filter"`
type MatchersBuilder ¶
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 MultiStageExpr ¶
type MultiStageExpr []StageExpr
MultiStageExpr is multiple stages which implement a PipelineExpr.
func (MultiStageExpr) String ¶
func (m MultiStageExpr) String() string
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 ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
ParseError is what is returned when we failed to parse.
func (ParseError) Error ¶
func (p ParseError) Error() string
func (ParseError) Is ¶
func (p ParseError) Is(target error) bool
Is allows to use errors.Is(err,ErrParse) on this error.
type PipelineBuilder ¶
type PipelineBuilder interface {
AddLabelFilterer(labelFilterer log.LabelFilterer)
}
type PipelineExpr ¶
PipelineExpr is an expression defining a log pipeline.
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 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, bool) Close() error Error() error }
RangeVectorIterator iterates through a range of samples. To fetch the current vector use `At` with a `RangeVectorAggregator`.
type Result ¶
type Result struct { Data promql_parser.Value Statistics stats.Result }
Result is the result of a query execution.
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 SampleExpr, p Params, ) (StepEvaluator, error) }
type SampleEvaluatorFunc ¶
type SampleEvaluatorFunc func(ctx context.Context, nextEvaluator SampleEvaluator, expr SampleExpr, p Params) (StepEvaluator, error)
func (SampleEvaluatorFunc) StepEvaluator ¶
func (s SampleEvaluatorFunc) StepEvaluator( ctx context.Context, nextEvaluator SampleEvaluator, expr SampleExpr, p Params, ) (StepEvaluator, error)
type SampleExpr ¶
type SampleExpr interface { // Selector is the LogQL selector to apply when retrieving logs. Selector() LogSelectorExpr Extractor() (SampleExtractor, error) Expr }
SampleExpr is a LogQL expression filtering logs and returning metric samples.
func ParseSampleExpr ¶
func ParseSampleExpr(input string) (SampleExpr, error)
ParseSampleExpr parses a string and returns the sampleExpr
type SampleExtractor ¶
type SampleExtractor = log.SampleExtractor
Type alias for backward compatibility
type SelectLogParams ¶
type SelectLogParams struct {
*logproto.QueryRequest
}
SelectParams specifies parameters passed to data selections.
func (SelectLogParams) LogSelector ¶
func (s SelectLogParams) LogSelector() (LogSelectorExpr, error)
LogSelector returns the LogSelectorExpr from the SelectParams. The `LogSelectorExpr` can then returns all matchers and filters to use for that request.
type SelectSampleParams ¶
type SelectSampleParams struct {
*logproto.SampleQueryRequest
}
func (SelectSampleParams) Expr ¶
func (s SelectSampleParams) Expr() (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() (LogSelectorExpr, error)
LogSelector returns the LogSelectorExpr from the SelectParams. The `LogSelectorExpr` can then returns all matchers and filters to use for that request.
type StepEvaluator ¶
type StepEvaluator interface { // while Next returns a promql.Value, the only acceptable types are Scalar and Vector. Next() (bool, int64, promql.Vector) // Close all resources used. Close() error // Reports any error Error() error }
StepEvaluator evaluate a single step of a query.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
jsonexpr
Code generated by goyacc -l -p JSONExpr -o pkg/logql/log/jsonexpr/jsonexpr.y.go pkg/logql/log/jsonexpr/jsonexpr.y.
|
Code generated by goyacc -l -p JSONExpr -o pkg/logql/log/jsonexpr/jsonexpr.y.go pkg/logql/log/jsonexpr/jsonexpr.y. |
logfmt
Adapted from https://github.com/go-logfmt/logfmt/ but []byte as parameter instead Original license is MIT.
|
Adapted from https://github.com/go-logfmt/logfmt/ but []byte as parameter instead Original license is MIT. |
Package marshal converts internal objects to loghttp model objects.
|
Package marshal converts internal objects to loghttp model objects. |
Package stats provides primitives for recording metrics across the query path.
|
Package stats provides primitives for recording metrics across the query path. |