Documentation ¶
Index ¶
- Constants
- func IsComparisonOperator(op string) bool
- func IsLogicalBinOp(op string) bool
- func MatchersString(xs []*labels.Matcher) string
- 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
- func (e *LabelReplaceExpr) Extractor() (SampleExtractor, error)
- func (e *LabelReplaceExpr) MatcherGroups() []MatcherRange
- func (e *LabelReplaceExpr) Selector() LogSelectorExpr
- func (e *LabelReplaceExpr) Shardable() bool
- func (e *LabelReplaceExpr) String() string
- func (e *LabelReplaceExpr) Walk(f WalkFn)
- type LineFilterExpr
- type LineFmtExpr
- type LiteralExpr
- func (e *LiteralExpr) Extractor() (log.SampleExtractor, error)
- func (e *LiteralExpr) HasFilter() bool
- func (e *LiteralExpr) MatcherGroups() []MatcherRange
- 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 MatcherRange
- 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
- func (r RangeAggregationExpr) Extractor() (log.SampleExtractor, error)
- func (e *RangeAggregationExpr) MatcherGroups() []MatcherRange
- func (e *RangeAggregationExpr) Selector() LogSelectorExpr
- func (e *RangeAggregationExpr) Shardable() bool
- func (e *RangeAggregationExpr) String() string
- func (e RangeAggregationExpr) Validate() error
- func (e *RangeAggregationExpr) Walk(f WalkFn)
- type SampleExpr
- type SampleExtractor
- type StageExpr
- type UnwrapExpr
- type VectorAggregationExpr
- func (e *VectorAggregationExpr) Extractor() (log.SampleExtractor, error)
- func (e *VectorAggregationExpr) MatcherGroups() []MatcherRange
- func (e *VectorAggregationExpr) Selector() LogSelectorExpr
- func (e *VectorAggregationExpr) Shardable() bool
- func (e *VectorAggregationExpr) String() string
- func (e *VectorAggregationExpr) Walk(f WalkFn)
- 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" OpRangeTypeRateCounter = "rate_counter" 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 = 57403
const ADD = 57422
const AND = 57414
const AVG = 57373
const AVG_OVER_TIME = 57391
const BOOL = 57383
const BOTTOMK = 57379
const BY = 57367
const BYTES = 57346
const BYTES_CONV = 57398
const BYTES_OVER_TIME = 57381
const BYTES_RATE = 57382
const CLOSE_BRACE = 57358
const CLOSE_BRACKET = 57360
const CLOSE_PARENTHESIS = 57366
const CMP_EQ = 57416
const COMMA = 57361
const COUNT = 57376
const COUNT_OVER_TIME = 57369
const DIV = 57425
const DOT = 57362
const DURATION = 57350
const DURATION_CONV = 57399
const DURATION_SECONDS_CONV = 57400
const EQ = 57354
const (
EmptyMatchers = "{}"
)
const FIRST_OVER_TIME = 57401
const GROUP_LEFT = 57411
const GROUP_RIGHT = 57412
const GT = 57420
const GTE = 57421
const IDENTIFIER = 57347
const IGNORING = 57410
const IP = 57408
const JSON = 57384
const LABELS = 57353
const LABEL_FMT = 57389
const LABEL_REPLACE = 57404
const LAST_OVER_TIME = 57402
const LINE_FMT = 57388
const LOGFMT = 57386
const LT = 57418
const LTE = 57419
const MATCHERS = 57352
const MAX = 57374
const MAX_OVER_TIME = 57394
const MIN = 57375
const MIN_OVER_TIME = 57393
const MOD = 57426
const MUL = 57424
const NEQ = 57417
const NRE = 57356
const NUMBER = 57349
const OFFSET = 57406
const ON = 57409
const OPEN_BRACE = 57357
const OPEN_BRACKET = 57359
const OPEN_PARENTHESIS = 57365
const OR = 57413
const PATTERN = 57407
const PIPE = 57387
const PIPE_EXACT = 57364
const PIPE_MATCH = 57363
const POW = 57427
const QUANTILE_OVER_TIME = 57397
const RANGE = 57351
const RATE = 57370
const RATE_COUNTER = 57371
const RE = 57355
const REGEXP = 57385
const STDDEV = 57377
const STDDEV_OVER_TIME = 57396
const STDVAR = 57378
const STDVAR_OVER_TIME = 57395
const STRING = 57348
const SUB = 57423
const SUM = 57372
const SUM_OVER_TIME = 57392
const TOPK = 57380
const UNLESS = 57415
const UNPACK = 57405
const UNWRAP = 57390
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 MatchersString ¶
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 }
func (*BinOpExpr) MatcherGroups ¶
func (e *BinOpExpr) MatcherGroups() []MatcherRange
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) MatcherGroups ¶
func (e *LabelReplaceExpr) MatcherGroups() []MatcherRange
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) MatcherGroups ¶
func (e *LiteralExpr) MatcherGroups() []MatcherRange
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 MatcherRange ¶
func MatcherGroups ¶
func MatcherGroups(expr Expr) []MatcherRange
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) MatcherGroups ¶
func (e *RangeAggregationExpr) MatcherGroups() []MatcherRange
func (*RangeAggregationExpr) Selector ¶
func (e *RangeAggregationExpr) Selector() LogSelectorExpr
func (*RangeAggregationExpr) Shardable ¶
func (e *RangeAggregationExpr) Shardable() bool
impl SampleExpr
func (RangeAggregationExpr) Validate ¶
func (e RangeAggregationExpr) Validate() error
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) MatcherGroups() []MatcherRange 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) MatcherGroups ¶
func (e *VectorAggregationExpr) MatcherGroups() []MatcherRange
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.