Documentation ¶
Index ¶
- Constants
- func IsComparisonOperator(op string) bool
- func IsLogicalBinOp(op string) bool
- func MergeBinOp(op string, left, right *promql.Sample, filter, isVectorComparison bool) *promql.Sample
- func ParseLabels(lbs string) (labels.Labels, error)
- func ParseMatchers(input string) ([]*labels.Matcher, error)
- type BinOpExpr
- type BinOpOptions
- type Expr
- type Grouping
- type JSONExpressionParser
- type LabelFilterExpr
- type LabelFmtExpr
- type LabelParserExpr
- type LabelReplaceExpr
- type LineFilterExpr
- type LineFmtExpr
- type LiteralExpr
- func (e *LiteralExpr) Extractor() (log.SampleExtractor, error)
- func (e *LiteralExpr) HasFilter() bool
- func (e *LiteralExpr) Matchers() []*labels.Matcher
- func (e *LiteralExpr) Pipeline() (log.Pipeline, error)
- func (e *LiteralExpr) Selector() LogSelectorExpr
- func (e *LiteralExpr) Shardable() bool
- func (e *LiteralExpr) String() string
- func (e *LiteralExpr) Value() float64
- func (e *LiteralExpr) Walk(f WalkFn)
- type LogPipelineExpr
- type LogRange
- type LogSelectorExpr
- type MatchersExpr
- func (e *MatchersExpr) AppendMatchers(m []*labels.Matcher)
- func (e *MatchersExpr) HasFilter() bool
- func (e *MatchersExpr) Matchers() []*labels.Matcher
- func (e *MatchersExpr) Pipeline() (log.Pipeline, error)
- func (e *MatchersExpr) Shardable() bool
- func (e *MatchersExpr) String() string
- func (e *MatchersExpr) Walk(f WalkFn)
- type MultiStageExpr
- type OffsetExpr
- type Pipeline
- type PipelineExpr
- type RangeAggregationExpr
- type SampleExpr
- type SampleExtractor
- type StageExpr
- type UnwrapExpr
- type VectorAggregationExpr
- type VectorMatchCardinality
- type VectorMatching
- type WalkFn
- type Walkable
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" OpRangeTypeFirst = "first_over_time" OpRangeTypeLast = "last_over_time" OpRangeTypeAbsent = "absent_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" OpParserTypeUnpack = "unpack" OpParserTypePattern = "pattern" OpFmtLine = "line_format" OpFmtLabel = "label_format" OpPipe = "|" OpUnwrap = "unwrap" OpOffset = "offset" OpOn = "on" OpIgnoring = "ignoring" OpGroupLeft = "group_left" OpGroupRight = "group_right" // conversion Op OpConvBytes = "bytes" OpConvDuration = "duration" OpConvDurationSeconds = "duration_seconds" OpLabelReplace = "label_replace" // function filters OpFilterIP = "ip" )
const ABSENT_OVER_TIME = 57402
const ADD = 57421
const AND = 57413
const AVG = 57372
const AVG_OVER_TIME = 57390
const BOOL = 57382
const BOTTOMK = 57378
const BY = 57367
const BYTES = 57346
const BYTES_CONV = 57397
const BYTES_OVER_TIME = 57380
const BYTES_RATE = 57381
const CLOSE_BRACE = 57358
const CLOSE_BRACKET = 57360
const CLOSE_PARENTHESIS = 57366
const CMP_EQ = 57415
const COMMA = 57361
const COUNT = 57375
const COUNT_OVER_TIME = 57369
const DIV = 57424
const DOT = 57362
const DURATION = 57350
const DURATION_CONV = 57398
const DURATION_SECONDS_CONV = 57399
const EQ = 57354
const FIRST_OVER_TIME = 57400
const GROUP_LEFT = 57410
const GROUP_RIGHT = 57411
const GT = 57419
const GTE = 57420
const IDENTIFIER = 57347
const IGNORING = 57409
const IP = 57407
const JSON = 57383
const LABELS = 57353
const LABEL_FMT = 57388
const LABEL_REPLACE = 57403
const LAST_OVER_TIME = 57401
const LINE_FMT = 57387
const LOGFMT = 57385
const LT = 57417
const LTE = 57418
const MATCHERS = 57352
const MAX = 57373
const MAX_OVER_TIME = 57393
const MIN = 57374
const MIN_OVER_TIME = 57392
const MOD = 57425
const MUL = 57423
const NEQ = 57416
const NRE = 57356
const NUMBER = 57349
const OFFSET = 57405
const ON = 57408
const OPEN_BRACE = 57357
const OPEN_BRACKET = 57359
const OPEN_PARENTHESIS = 57365
const OR = 57412
const PATTERN = 57406
const PIPE = 57386
const PIPE_EXACT = 57364
const PIPE_MATCH = 57363
const POW = 57426
const QUANTILE_OVER_TIME = 57396
const RANGE = 57351
const RATE = 57370
const RE = 57355
const REGEXP = 57384
const STDDEV = 57376
const STDDEV_OVER_TIME = 57395
const STDVAR = 57377
const STDVAR_OVER_TIME = 57394
const STRING = 57348
const SUB = 57422
const SUM = 57371
const SUM_OVER_TIME = 57391
const TOPK = 57379
const UNLESS = 57414
const UNPACK = 57404
const UNWRAP = 57389
const UnsupportedErr = "unsupported range vector aggregation operation: %s"
const WITHOUT = 57368
Variables ¶
This section is empty.
Functions ¶
func IsComparisonOperator ¶
func IsLogicalBinOp ¶
IsLogicalBinOp tests whether an operation is a logical/set binary operation
func MergeBinOp ¶
func ParseLabels ¶
ParseLabels parses labels from a string using logql parser.
Types ¶
type BinOpExpr ¶
type BinOpExpr struct { SampleExpr RHS SampleExpr Op string Opts *BinOpOptions }
type BinOpOptions ¶
type BinOpOptions struct { ReturnBool bool VectorMatching *VectorMatching }
type Expr ¶
type Expr interface { Shardable() bool // A recursive check on the AST to see if it's shardable. Walkable fmt.Stringer // contains filtered or unexported methods }
Expr is the root expression which can be a SampleExpr or LogSelectorExpr
type JSONExpressionParser ¶
type JSONExpressionParser struct { Expressions []log.JSONExpression // contains filtered or unexported fields }
func (*JSONExpressionParser) Shardable ¶
func (j *JSONExpressionParser) Shardable() bool
func (*JSONExpressionParser) String ¶
func (j *JSONExpressionParser) String() string
func (*JSONExpressionParser) Walk ¶
func (j *JSONExpressionParser) Walk(f WalkFn)
type LabelFilterExpr ¶
type LabelFilterExpr struct { log.LabelFilterer // contains filtered or unexported fields }
func (*LabelFilterExpr) Shardable ¶
func (e *LabelFilterExpr) Shardable() bool
func (*LabelFilterExpr) String ¶
func (e *LabelFilterExpr) String() string
func (*LabelFilterExpr) Walk ¶
func (e *LabelFilterExpr) Walk(f WalkFn)
type LabelFmtExpr ¶
func (*LabelFmtExpr) Shardable ¶
func (e *LabelFmtExpr) Shardable() bool
func (*LabelFmtExpr) String ¶
func (e *LabelFmtExpr) String() string
func (*LabelFmtExpr) Walk ¶
func (e *LabelFmtExpr) Walk(f WalkFn)
type LabelParserExpr ¶
func (*LabelParserExpr) Shardable ¶
func (e *LabelParserExpr) Shardable() bool
func (*LabelParserExpr) String ¶
func (e *LabelParserExpr) String() string
func (*LabelParserExpr) Walk ¶
func (e *LabelParserExpr) Walk(f WalkFn)
type LabelReplaceExpr ¶
type LabelReplaceExpr struct { Left SampleExpr Dst string Replacement string Src string Regex string Re *regexp.Regexp // contains filtered or unexported fields }
func (*LabelReplaceExpr) Extractor ¶
func (e *LabelReplaceExpr) Extractor() (SampleExtractor, error)
func (*LabelReplaceExpr) Selector ¶
func (e *LabelReplaceExpr) Selector() LogSelectorExpr
func (*LabelReplaceExpr) Shardable ¶
func (e *LabelReplaceExpr) Shardable() bool
func (*LabelReplaceExpr) String ¶
func (e *LabelReplaceExpr) String() string
func (*LabelReplaceExpr) Walk ¶
func (e *LabelReplaceExpr) Walk(f WalkFn)
type LineFilterExpr ¶
type LineFilterExpr struct { Left *LineFilterExpr Ty labels.MatchType Match string Op string // contains filtered or unexported fields }
func (*LineFilterExpr) Shardable ¶
func (e *LineFilterExpr) Shardable() bool
func (*LineFilterExpr) String ¶
func (e *LineFilterExpr) String() string
func (*LineFilterExpr) Walk ¶
func (e *LineFilterExpr) Walk(f WalkFn)
type LineFmtExpr ¶
type LineFmtExpr struct { Value string // contains filtered or unexported fields }
func (*LineFmtExpr) Shardable ¶
func (e *LineFmtExpr) Shardable() bool
func (*LineFmtExpr) String ¶
func (e *LineFmtExpr) String() string
func (*LineFmtExpr) Walk ¶
func (e *LineFmtExpr) Walk(f WalkFn)
type LiteralExpr ¶
type LiteralExpr struct { Val float64 // contains filtered or unexported fields }
func (*LiteralExpr) Extractor ¶
func (e *LiteralExpr) Extractor() (log.SampleExtractor, error)
func (*LiteralExpr) HasFilter ¶
func (e *LiteralExpr) HasFilter() bool
func (*LiteralExpr) Matchers ¶
func (e *LiteralExpr) Matchers() []*labels.Matcher
func (*LiteralExpr) Selector ¶
func (e *LiteralExpr) Selector() LogSelectorExpr
literlExpr impls SampleExpr & LogSelectorExpr mainly to reduce the need for more complicated typings to facilitate sum types. We'll be type switching when evaluating them anyways and they will only be present in binary operation legs.
func (*LiteralExpr) Shardable ¶
func (e *LiteralExpr) Shardable() bool
func (*LiteralExpr) String ¶
func (e *LiteralExpr) String() string
func (*LiteralExpr) Value ¶
func (e *LiteralExpr) Value() float64
func (*LiteralExpr) Walk ¶
func (e *LiteralExpr) Walk(f WalkFn)
type LogPipelineExpr ¶
LogPipelineExpr is an expression defining a log pipeline.
type LogRange ¶
type LogRange struct { Left LogSelectorExpr Interval time.Duration Offset time.Duration Unwrap *UnwrapExpr // contains filtered or unexported fields }
type LogSelectorExpr ¶
type LogSelectorExpr interface { Matchers() []*labels.Matcher LogPipelineExpr HasFilter() bool Expr }
LogSelectorExpr is a LogQL expression filtering and returning logs.
func AddFilterExpr ¶
func AddFilterExpr(expr LogSelectorExpr, ty labels.MatchType, op, match string) (LogSelectorExpr, error)
AddFilterExpr adds a filter expression to a logselector expression.
func ParseLogSelector ¶
func ParseLogSelector(input string, validate bool) (LogSelectorExpr, error)
ParseLogSelector parses a log selector expression `{app="foo"} |= "filter"`
type MatchersExpr ¶
func (*MatchersExpr) AppendMatchers ¶
func (e *MatchersExpr) AppendMatchers(m []*labels.Matcher)
func (*MatchersExpr) HasFilter ¶
func (e *MatchersExpr) HasFilter() bool
func (*MatchersExpr) Matchers ¶
func (e *MatchersExpr) Matchers() []*labels.Matcher
func (*MatchersExpr) Shardable ¶
func (e *MatchersExpr) Shardable() bool
func (*MatchersExpr) String ¶
func (e *MatchersExpr) String() string
func (*MatchersExpr) Walk ¶
func (e *MatchersExpr) Walk(f WalkFn)
type MultiStageExpr ¶
type MultiStageExpr []StageExpr
MultiStageExpr is multiple stages which implement a PipelineExpr.
func (MultiStageExpr) String ¶
func (m MultiStageExpr) String() string
type OffsetExpr ¶
func (*OffsetExpr) String ¶
func (o *OffsetExpr) String() string
type PipelineExpr ¶
type PipelineExpr struct { MultiStages MultiStageExpr Left *MatchersExpr // contains filtered or unexported fields }
func (*PipelineExpr) HasFilter ¶
func (e *PipelineExpr) HasFilter() bool
HasFilter returns true if the pipeline contains stage that can filter out lines.
func (*PipelineExpr) Matchers ¶
func (e *PipelineExpr) Matchers() []*labels.Matcher
func (*PipelineExpr) Shardable ¶
func (e *PipelineExpr) Shardable() bool
func (*PipelineExpr) String ¶
func (e *PipelineExpr) String() string
func (*PipelineExpr) Walk ¶
func (e *PipelineExpr) Walk(f WalkFn)
type RangeAggregationExpr ¶
type RangeAggregationExpr struct { Left *LogRange Operation string Params *float64 Grouping *Grouping // contains filtered or unexported fields }
func (RangeAggregationExpr) Extractor ¶
func (r RangeAggregationExpr) Extractor() (log.SampleExtractor, error)
func (*RangeAggregationExpr) Selector ¶
func (e *RangeAggregationExpr) Selector() LogSelectorExpr
func (*RangeAggregationExpr) Shardable ¶
func (e *RangeAggregationExpr) Shardable() bool
impl SampleExpr
func (*RangeAggregationExpr) Walk ¶
func (e *RangeAggregationExpr) Walk(f WalkFn)
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 UnwrapExpr ¶
type UnwrapExpr struct { Identifier string Operation string PostFilters []log.LabelFilterer }
func (UnwrapExpr) String ¶
func (u UnwrapExpr) String() string
type VectorAggregationExpr ¶
type VectorAggregationExpr struct { Left SampleExpr Grouping *Grouping Params int Operation string // contains filtered or unexported fields }
func (*VectorAggregationExpr) Extractor ¶
func (e *VectorAggregationExpr) Extractor() (log.SampleExtractor, error)
func (*VectorAggregationExpr) Selector ¶
func (e *VectorAggregationExpr) Selector() LogSelectorExpr
func (*VectorAggregationExpr) Shardable ¶
func (e *VectorAggregationExpr) Shardable() bool
impl SampleExpr
func (*VectorAggregationExpr) String ¶
func (e *VectorAggregationExpr) String() string
func (*VectorAggregationExpr) Walk ¶
func (e *VectorAggregationExpr) Walk(f WalkFn)
type VectorMatchCardinality ¶
type VectorMatchCardinality int
VectorMatchCardinality describes the cardinality relationship of two Vectors in a binary operation.
const ( CardOneToOne VectorMatchCardinality = iota CardManyToOne CardOneToMany )
func (VectorMatchCardinality) String ¶
func (vmc VectorMatchCardinality) String() string
type VectorMatching ¶
type VectorMatching struct { // The cardinality of the two Vectors. Card VectorMatchCardinality // MatchingLabels contains the labels which define equality of a pair of // elements from the Vectors. MatchingLabels []string // On includes the given label names from matching, // rather than excluding them. On bool // Include contains additional labels that should be included in // the result from the side with the lower cardinality. Include []string }
VectorMatching describes how elements from two Vectors in a binary operation are supposed to be matched.