Documentation ¶
Overview ¶
This file is taken from the golang text/scanner package so `bufLen` can be set to `maxInputSize`.
Index ¶
- Constants
- Variables
- func AssertExpressions(t *testing.T, expected, actual Expr)
- func AssertMatchers(t *testing.T, expected, actual []*labels.Matcher)
- func Clone[T Expr](e T) (T, error)
- func EncodeJSON(e Expr, w io.Writer) error
- func Indent(level int) string
- func IsComparisonOperator(op string) bool
- func IsLogicalBinOp(op string) bool
- func IsMatchEqualFilterer(filterer log.LabelFilterer) bool
- func MatchersString(xs []*labels.Matcher) string
- func MergeBinOp(op string, left, right *promql.Sample, swap, filter, isVectorComparison bool) (*promql.Sample, error)
- func MustClone[T Expr](e T) T
- func NeedSplit(e Expr) bool
- func ParseLabels(lbs string) (labels.Labels, error)
- func ParseMatchers(input string, validate bool) ([]*labels.Matcher, error)
- func Prettify(e Expr) string
- func ReducesLabels(e Expr) (conflict bool)
- func RemoveFastRegexMatchers(matchers []*labels.Matcher) []*labels.Matcher
- func SplitFiltersAndMatchers(allMatchers []*labels.Matcher) (filters, matchers []*labels.Matcher)
- func TokenString(tok rune) string
- type AcceptVisitor
- type BinOpExpr
- type BinOpOptions
- type DecolorizeExpr
- type DepthFirstTraversal
- func (v *DepthFirstTraversal) VisitBinOp(e *BinOpExpr)
- func (v *DepthFirstTraversal) VisitDecolorize(e *DecolorizeExpr)
- func (v *DepthFirstTraversal) VisitDropLabels(e *DropLabelsExpr)
- func (v *DepthFirstTraversal) VisitJSONExpressionParser(e *JSONExpressionParser)
- func (v *DepthFirstTraversal) VisitKeepLabel(e *KeepLabelsExpr)
- func (v *DepthFirstTraversal) VisitLabelFilter(e *LabelFilterExpr)
- func (v *DepthFirstTraversal) VisitLabelFmt(e *LabelFmtExpr)
- func (v *DepthFirstTraversal) VisitLabelParser(e *LabelParserExpr)
- func (v *DepthFirstTraversal) VisitLabelReplace(e *LabelReplaceExpr)
- func (v *DepthFirstTraversal) VisitLineFilter(e *LineFilterExpr)
- func (v *DepthFirstTraversal) VisitLineFmt(e *LineFmtExpr)
- func (v *DepthFirstTraversal) VisitLiteral(e *LiteralExpr)
- func (v *DepthFirstTraversal) VisitLogRange(e *LogRange)
- func (v *DepthFirstTraversal) VisitLogfmtExpressionParser(e *LogfmtExpressionParser)
- func (v *DepthFirstTraversal) VisitLogfmtParser(e *LogfmtParserExpr)
- func (v *DepthFirstTraversal) VisitMatchers(e *MatchersExpr)
- func (v *DepthFirstTraversal) VisitPipeline(e *PipelineExpr)
- func (v *DepthFirstTraversal) VisitRangeAggregation(e *RangeAggregationExpr)
- func (v *DepthFirstTraversal) VisitVector(e *VectorExpr)
- func (v *DepthFirstTraversal) VisitVectorAggregation(e *VectorAggregationExpr)
- type DropLabelsExpr
- type Expr
- type Grouping
- type JSONExpressionParser
- func (j *JSONExpressionParser) Accept(v RootVisitor)
- func (e *JSONExpressionParser) Pretty(level int) string
- func (j *JSONExpressionParser) Shardable(_ bool) bool
- func (j *JSONExpressionParser) Stage() (log.Stage, error)
- func (j *JSONExpressionParser) String() string
- func (j *JSONExpressionParser) Walk(f WalkFn)
- type JSONSerializer
- func (v *JSONSerializer) VisitBinOp(e *BinOpExpr)
- func (*JSONSerializer) VisitDecolorize(*DecolorizeExpr)
- func (*JSONSerializer) VisitDropLabels(*DropLabelsExpr)
- func (*JSONSerializer) VisitJSONExpressionParser(*JSONExpressionParser)
- func (*JSONSerializer) VisitKeepLabel(*KeepLabelsExpr)
- func (*JSONSerializer) VisitLabelFilter(*LabelFilterExpr)
- func (*JSONSerializer) VisitLabelFmt(*LabelFmtExpr)
- func (*JSONSerializer) VisitLabelParser(*LabelParserExpr)
- func (v *JSONSerializer) VisitLabelReplace(e *LabelReplaceExpr)
- func (*JSONSerializer) VisitLineFilter(*LineFilterExpr)
- func (*JSONSerializer) VisitLineFmt(*LineFmtExpr)
- func (v *JSONSerializer) VisitLiteral(e *LiteralExpr)
- func (v *JSONSerializer) VisitLogRange(e *LogRange)
- func (*JSONSerializer) VisitLogfmtExpressionParser(*LogfmtExpressionParser)
- func (*JSONSerializer) VisitLogfmtParser(*LogfmtParserExpr)
- func (v *JSONSerializer) VisitMatchers(e *MatchersExpr)
- func (v *JSONSerializer) VisitPipeline(e *PipelineExpr)
- func (v *JSONSerializer) VisitRangeAggregation(e *RangeAggregationExpr)
- func (v *JSONSerializer) VisitVector(e *VectorExpr)
- func (v *JSONSerializer) VisitVectorAggregation(e *VectorAggregationExpr)
- type KeepLabelsExpr
- type LabelFilterExpr
- type LabelFmtExpr
- type LabelParserExpr
- type LabelReplaceExpr
- func (e *LabelReplaceExpr) Accept(v RootVisitor)
- func (e *LabelReplaceExpr) Extractor() (SampleExtractor, error)
- func (e *LabelReplaceExpr) MatcherGroups() ([]MatcherRange, error)
- func (e *LabelReplaceExpr) Pretty(level int) string
- func (e *LabelReplaceExpr) Selector() (LogSelectorExpr, error)
- func (e *LabelReplaceExpr) Shardable(_ bool) bool
- func (e *LabelReplaceExpr) String() string
- func (e *LabelReplaceExpr) Walk(f WalkFn)
- type LineFilter
- type LineFilterExpr
- func (e *LineFilterExpr) Accept(v RootVisitor)
- func (e *LineFilterExpr) Filter() (log.Filterer, error)
- func (e *LineFilterExpr) Pretty(level int) string
- func (e *LineFilterExpr) Shardable(_ bool) bool
- func (e *LineFilterExpr) Stage() (log.Stage, error)
- func (e *LineFilterExpr) String() string
- func (e *LineFilterExpr) Walk(f WalkFn)
- type LineFmtExpr
- type LiteralExpr
- func (e *LiteralExpr) Accept(v RootVisitor)
- func (e *LiteralExpr) Extractor() (log.SampleExtractor, error)
- func (e *LiteralExpr) HasFilter() bool
- func (e *LiteralExpr) MatcherGroups() ([]MatcherRange, error)
- func (e *LiteralExpr) Matchers() []*labels.Matcher
- func (e *LiteralExpr) Pipeline() (log.Pipeline, error)
- func (e *LiteralExpr) Pretty(level int) string
- func (e *LiteralExpr) Selector() (LogSelectorExpr, error)
- func (e *LiteralExpr) Shardable(_ bool) bool
- func (e *LiteralExpr) String() string
- func (e *LiteralExpr) Value() (float64, error)
- func (e *LiteralExpr) Walk(f WalkFn)
- type LogRange
- type LogSelectorExpr
- type LogSelectorExprVisitor
- type LogfmtExpressionParser
- func (l *LogfmtExpressionParser) Accept(v RootVisitor)
- func (e *LogfmtExpressionParser) Pretty(level int) string
- func (l *LogfmtExpressionParser) Shardable(_ bool) bool
- func (l *LogfmtExpressionParser) Stage() (log.Stage, error)
- func (l *LogfmtExpressionParser) String() string
- func (l *LogfmtExpressionParser) Walk(f WalkFn)
- type LogfmtParserExpr
- type MatcherRange
- type MatchersExpr
- func (e *MatchersExpr) Accept(v RootVisitor)
- 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) Pretty(level int) string
- func (e *MatchersExpr) Shardable(_ bool) bool
- func (e *MatchersExpr) String() string
- func (e *MatchersExpr) Walk(f WalkFn)
- type MultiStageExpr
- type OffsetExpr
- type ParseError
- type Pipeline
- type PipelineError
- type PipelineExpr
- func (e *PipelineExpr) Accept(v RootVisitor)
- func (e *PipelineExpr) HasFilter() bool
- func (e *PipelineExpr) Matchers() []*labels.Matcher
- func (e *PipelineExpr) Pipeline() (log.Pipeline, error)
- func (e *PipelineExpr) Pretty(level int) string
- func (e *PipelineExpr) Shardable(topLevel bool) bool
- func (e *PipelineExpr) String() string
- func (e *PipelineExpr) Walk(f WalkFn)
- type Position
- type RangeAggregationExpr
- func (e *RangeAggregationExpr) Accept(v RootVisitor)
- func (r RangeAggregationExpr) Extractor() (log.SampleExtractor, error)
- func (e *RangeAggregationExpr) MatcherGroups() ([]MatcherRange, error)
- func (e *RangeAggregationExpr) Pretty(level int) string
- func (e *RangeAggregationExpr) Selector() (LogSelectorExpr, error)
- func (e *RangeAggregationExpr) Shardable(topLevel bool) bool
- func (e *RangeAggregationExpr) String() string
- func (e RangeAggregationExpr) Validate() error
- func (e *RangeAggregationExpr) Walk(f WalkFn)
- type RootVisitor
- type SampleExpr
- type SampleExprVisitor
- type SampleExtractor
- type Scanner
- type StageExpr
- type StageExprVisitor
- type UnwrapExpr
- type VectorAggregationExpr
- func (e *VectorAggregationExpr) Accept(v RootVisitor)
- func (e *VectorAggregationExpr) Extractor() (log.SampleExtractor, error)
- func (e *VectorAggregationExpr) MatcherGroups() ([]MatcherRange, error)
- func (e *VectorAggregationExpr) Pretty(level int) string
- func (e *VectorAggregationExpr) Selector() (LogSelectorExpr, error)
- func (e *VectorAggregationExpr) Shardable(topLevel bool) bool
- func (e *VectorAggregationExpr) String() string
- func (e *VectorAggregationExpr) Walk(f WalkFn)
- type VectorExpr
- func (e *VectorExpr) Accept(v RootVisitor)
- func (e *VectorExpr) Err() error
- func (e *VectorExpr) Extractor() (log.SampleExtractor, error)
- func (e *VectorExpr) HasFilter() bool
- func (e *VectorExpr) MatcherGroups() ([]MatcherRange, error)
- func (e *VectorExpr) Matchers() []*labels.Matcher
- func (e *VectorExpr) Pipeline() (log.Pipeline, error)
- func (e *VectorExpr) Pretty(level int) string
- func (e *VectorExpr) Selector() (LogSelectorExpr, error)
- func (e *VectorExpr) Shardable(_ bool) bool
- func (e *VectorExpr) String() string
- func (e *VectorExpr) Value() (float64, error)
- func (e *VectorExpr) 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" OpTypeSort = "sort" OpTypeSortDesc = "sort_desc" // 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" // vector OpTypeVector = "vector" // binops - logical/set OpTypeOr = "or" OpTypeAnd = "and" OpTypeUnless = "unless" // binops - arithmetic 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" OpDecolorize = "decolorize" 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" // drop labels OpDrop = "drop" // keep labels OpKeep = "keep" // parser flags OpStrict = "--strict" OpKeepEmpty = "--keep-empty" // internal expressions not represented in LogQL. These are used to // evaluate expressions differently resulting in intermediate formats // that are not consumable by LogQL clients but are used for sharding. OpRangeTypeQuantileSketch = "__quantile_sketch_over_time__" OpRangeTypeFirstWithTimestamp = "__first_over_time_ts__" OpRangeTypeLastWithTimestamp = "__last_over_time_ts__" OpTypeCountMinSketch = "__count_min_sketch__" // probabilistic aggregations OpTypeApproxTopK = "approx_topk" )
const ( ScanIdents = 1 << -Ident ScanInts = 1 << -Int ScanFloats = 1 << -Float // includes Ints and hexadecimal floats ScanChars = 1 << -Char ScanStrings = 1 << -String ScanRawStrings = 1 << -RawString ScanComments = 1 << -Comment SkipComments = 1 << -skipComment // if set with ScanComments, comments become white space GoTokens = ScanIdents | ScanFloats | ScanChars | ScanStrings | ScanRawStrings | ScanComments | SkipComments )
Predefined mode bits to control recognition of tokens. For instance, to configure a Scanner such that it only recognizes (Go) identifiers, integers, and skips comments, set the Scanner's Mode field to:
ScanIdents | ScanInts | SkipComments
With the exceptions of comments, which are skipped if SkipComments is set, unrecognized tokens are not ignored. Instead, the scanner simply returns the respective individual characters (or possibly sub-tokens). For instance, if the mode is ScanIdents (not ScanStrings), the string "foo" is scanned as the token sequence '"' Ident '"'.
Use GoTokens to configure the Scanner such that it accepts all Go literal tokens including Go identifiers. Comments will be skipped.
const ( EOF = -(iota + 1) Ident Int Float Char String RawString Comment )
The result of Scan is one of these tokens or a Unicode character.
const ( Bin = "bin" Binary = "binary" Bytes = "bytes" And = "and" Card = "cardinality" Dst = "dst" Duration = "duration" Groups = "groups" GroupingField = "grouping" Include = "include" Identifier = "identifier" Inner = "inner" IntervalNanos = "interval_nanos" IPField = "ip" Label = "label" LabelReplace = "label_replace" LHS = "lhs" Literal = "literal" LogSelector = "log_selector" Name = "name" Numeric = "numeric" MatchingLabels = "matching_labels" On = "on" Op = "operation" Options = "options" OffsetNanos = "offset_nanos" Params = "params" Pattern = "pattern" PostFilterers = "post_filterers" Range = "range" RangeAgg = "range_agg" Raw = "raw" RegexField = "regex" Replacement = "replacement" ReturnBool = "return_bool" RHS = "rhs" Src = "src" StringField = "string" NoopField = "noop" Type = "type" Unwrap = "unwrap" Value = "value" Vector = "vector" VectorAgg = "vector_agg" VectorMatchingField = "vector_matching" Without = "without" )
Field names
const ABSENT_OVER_TIME = 57409
const ADD = 57432
const AND = 57424
const APPROX_TOPK = 57386
const AVG = 57378
const AVG_OVER_TIME = 57397
const BOOL = 57389
const BOTTOMK = 57384
const BY = 57370
const BYTES = 57346
const BYTES_CONV = 57404
const BYTES_OVER_TIME = 57387
const BYTES_RATE = 57388
const CLOSE_BRACE = 57360
const CLOSE_BRACKET = 57362
const CLOSE_PARENTHESIS = 57369
const CMP_EQ = 57426
const COMMA = 57363
const COUNT = 57381
const COUNT_OVER_TIME = 57372
const DECOLORIZE = 57420
const DIV = 57435
const DOT = 57364
const DROP = 57421
const DURATION = 57351
const DURATION_CONV = 57405
const DURATION_SECONDS_CONV = 57406
const EQ = 57355
const (
EmptyMatchers = "{}"
)
const FIRST_OVER_TIME = 57407
const GROUP_LEFT = 57418
const GROUP_RIGHT = 57419
const GT = 57430
const GTE = 57431
const GoWhitespace = 1<<'\t' | 1<<'\n' | 1<<'\r' | 1<<' '
GoWhitespace is the default value for the Scanner's Whitespace field. Its value selects Go's white space characters.
const IDENTIFIER = 57347
const IGNORING = 57417
const IP = 57415
const JSON = 57390
const KEEP = 57422
const LABELS = 57354
const LABEL_FMT = 57395
const LABEL_REPLACE = 57411
const LAST_OVER_TIME = 57408
const LINE_FMT = 57394
const LOGFMT = 57392
const LT = 57428
const LTE = 57429
const MATCHERS = 57353
const MAX = 57379
const MAX_OVER_TIME = 57400
const MIN = 57380
const MIN_OVER_TIME = 57399
const MOD = 57436
const MUL = 57434
const NEQ = 57427
const NPA = 57358
const NRE = 57357
const NUMBER = 57349
const OFFSET = 57413
const ON = 57416
const OPEN_BRACE = 57359
const OPEN_BRACKET = 57361
const OPEN_PARENTHESIS = 57368
const OR = 57423
const PARSER_FLAG = 57350
const PATTERN = 57414
const PIPE = 57393
const PIPE_EXACT = 57366
const PIPE_MATCH = 57365
const PIPE_PATTERN = 57367
const POW = 57437
const QUANTILE_OVER_TIME = 57403
const RANGE = 57352
const RATE = 57373
const RATE_COUNTER = 57374
const RE = 57356
const REGEXP = 57391
const SORT = 57376
const SORT_DESC = 57377
const STDDEV = 57382
const STDDEV_OVER_TIME = 57402
const STDVAR = 57383
const STDVAR_OVER_TIME = 57401
const STRING = 57348
const SUB = 57433
const SUM = 57375
const SUM_OVER_TIME = 57398
const TOPK = 57385
const UNLESS = 57425
const UNPACK = 57412
const UNWRAP = 57396
const UnsupportedErr = "unsupported range vector aggregation operation: %s"
const VECTOR = 57410
const WITHOUT = 57371
Variables ¶
var ( ErrParse = errors.New("failed to parse the log query") ErrPipeline = errors.New("failed execute pipeline") ErrParseMatchers = errors.New("only label matchers are supported") )
var (
// MaxCharsPerLine is used to qualify whether some LogQL expressions are worth `splitting` into new lines.
MaxCharsPerLine = 100
)
Functions ¶
func AssertExpressions ¶
AssertExpressions function removes FastRegexMatchers from all Regexp matchers to allow simple objects comparison. See removeFastRegexMatcherFromExpr function for the details.
func AssertMatchers ¶
AssertMatchers function removes FastRegexMatchers from all Regexp matchers to allow simple objects comparison.
func IsComparisonOperator ¶
func IsLogicalBinOp ¶
IsLogicalBinOp tests whether an operation is a logical/set binary operation
func IsMatchEqualFilterer ¶
func IsMatchEqualFilterer(filterer log.LabelFilterer) bool
func MatchersString ¶
func MergeBinOp ¶
func MergeBinOp(op string, left, right *promql.Sample, swap, filter, isVectorComparison bool) (*promql.Sample, error)
MergeBinOp performs `op` on `left` and `right` arguments and return the `promql.Sample` value. In case of vector and scalar arguments, MergeBinOp assumes `left` is always vector. pass `swap=true` otherwise. This matters because, either it's (vector op scalar) or (scalar op vector), the return sample value should always be sample value of vector argument. https://github.com/grafana/loki/issues/10741
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 ReducesLabels ¶
func RemoveFastRegexMatchers ¶
RemoveFastRegexMatchers iterates over the matchers and recreates the matchers without *FastRegexMatcher, because Prometheus labels matcher sets a new instance each time it's created, and it prevents simple object assertions.
func SplitFiltersAndMatchers ¶
SplitFiltersAndMatchers splits empty matchers off, which are treated as filters, see #220
func TokenString ¶
TokenString returns a printable string for a token or Unicode character.
Types ¶
type AcceptVisitor ¶
type AcceptVisitor interface {
Accept(RootVisitor)
}
type BinOpExpr ¶
type BinOpExpr struct { SampleExpr RHS SampleExpr Op string Opts *BinOpOptions // contains filtered or unexported fields }
func (*BinOpExpr) Accept ¶
func (e *BinOpExpr) Accept(v RootVisitor)
func (*BinOpExpr) MatcherGroups ¶
func (e *BinOpExpr) MatcherGroups() ([]MatcherRange, error)
type BinOpOptions ¶
type BinOpOptions struct { ReturnBool bool VectorMatching *VectorMatching }
type DecolorizeExpr ¶
type DecolorizeExpr struct {
// contains filtered or unexported fields
}
func (*DecolorizeExpr) Accept ¶
func (e *DecolorizeExpr) Accept(v RootVisitor)
func (*DecolorizeExpr) Shardable ¶
func (e *DecolorizeExpr) Shardable(_ bool) bool
func (*DecolorizeExpr) String ¶
func (e *DecolorizeExpr) String() string
func (*DecolorizeExpr) Walk ¶
func (e *DecolorizeExpr) Walk(f WalkFn)
type DepthFirstTraversal ¶
type DepthFirstTraversal struct { VisitBinOpFn func(v RootVisitor, e *BinOpExpr) VisitDecolorizeFn func(v RootVisitor, e *DecolorizeExpr) VisitDropLabelsFn func(v RootVisitor, e *DropLabelsExpr) VisitJSONExpressionParserFn func(v RootVisitor, e *JSONExpressionParser) VisitKeepLabelFn func(v RootVisitor, e *KeepLabelsExpr) VisitLabelFilterFn func(v RootVisitor, e *LabelFilterExpr) VisitLabelFmtFn func(v RootVisitor, e *LabelFmtExpr) VisitLabelParserFn func(v RootVisitor, e *LabelParserExpr) VisitLabelReplaceFn func(v RootVisitor, e *LabelReplaceExpr) VisitLineFilterFn func(v RootVisitor, e *LineFilterExpr) VisitLineFmtFn func(v RootVisitor, e *LineFmtExpr) VisitLiteralFn func(v RootVisitor, e *LiteralExpr) VisitLogRangeFn func(v RootVisitor, e *LogRange) VisitLogfmtExpressionParserFn func(v RootVisitor, e *LogfmtExpressionParser) VisitLogfmtParserFn func(v RootVisitor, e *LogfmtParserExpr) VisitMatchersFn func(v RootVisitor, e *MatchersExpr) VisitPipelineFn func(v RootVisitor, e *PipelineExpr) VisitRangeAggregationFn func(v RootVisitor, e *RangeAggregationExpr) VisitVectorFn func(v RootVisitor, e *VectorExpr) VisitVectorAggregationFn func(v RootVisitor, e *VectorAggregationExpr) }
func (*DepthFirstTraversal) VisitBinOp ¶
func (v *DepthFirstTraversal) VisitBinOp(e *BinOpExpr)
VisitBinOp implements RootVisitor.
func (*DepthFirstTraversal) VisitDecolorize ¶
func (v *DepthFirstTraversal) VisitDecolorize(e *DecolorizeExpr)
VisitDecolorize implements RootVisitor.
func (*DepthFirstTraversal) VisitDropLabels ¶
func (v *DepthFirstTraversal) VisitDropLabels(e *DropLabelsExpr)
VisitDropLabels implements RootVisitor.
func (*DepthFirstTraversal) VisitJSONExpressionParser ¶
func (v *DepthFirstTraversal) VisitJSONExpressionParser(e *JSONExpressionParser)
VisitJSONExpressionParser implements RootVisitor.
func (*DepthFirstTraversal) VisitKeepLabel ¶
func (v *DepthFirstTraversal) VisitKeepLabel(e *KeepLabelsExpr)
VisitKeepLabel implements RootVisitor.
func (*DepthFirstTraversal) VisitLabelFilter ¶
func (v *DepthFirstTraversal) VisitLabelFilter(e *LabelFilterExpr)
VisitLabelFilter implements RootVisitor.
func (*DepthFirstTraversal) VisitLabelFmt ¶
func (v *DepthFirstTraversal) VisitLabelFmt(e *LabelFmtExpr)
VisitLabelFmt implements RootVisitor.
func (*DepthFirstTraversal) VisitLabelParser ¶
func (v *DepthFirstTraversal) VisitLabelParser(e *LabelParserExpr)
VisitLabelParser implements RootVisitor.
func (*DepthFirstTraversal) VisitLabelReplace ¶
func (v *DepthFirstTraversal) VisitLabelReplace(e *LabelReplaceExpr)
VisitLabelReplace implements RootVisitor.
func (*DepthFirstTraversal) VisitLineFilter ¶
func (v *DepthFirstTraversal) VisitLineFilter(e *LineFilterExpr)
VisitLineFilter implements RootVisitor.
func (*DepthFirstTraversal) VisitLineFmt ¶
func (v *DepthFirstTraversal) VisitLineFmt(e *LineFmtExpr)
VisitLineFmt implements RootVisitor.
func (*DepthFirstTraversal) VisitLiteral ¶
func (v *DepthFirstTraversal) VisitLiteral(e *LiteralExpr)
VisitLiteral implements RootVisitor.
func (*DepthFirstTraversal) VisitLogRange ¶
func (v *DepthFirstTraversal) VisitLogRange(e *LogRange)
VisitLogRange implements RootVisitor.
func (*DepthFirstTraversal) VisitLogfmtExpressionParser ¶
func (v *DepthFirstTraversal) VisitLogfmtExpressionParser(e *LogfmtExpressionParser)
VisitLogfmtExpressionParser implements RootVisitor.
func (*DepthFirstTraversal) VisitLogfmtParser ¶
func (v *DepthFirstTraversal) VisitLogfmtParser(e *LogfmtParserExpr)
VisitLogfmtParser implements RootVisitor.
func (*DepthFirstTraversal) VisitMatchers ¶
func (v *DepthFirstTraversal) VisitMatchers(e *MatchersExpr)
VisitMatchers implements RootVisitor.
func (*DepthFirstTraversal) VisitPipeline ¶
func (v *DepthFirstTraversal) VisitPipeline(e *PipelineExpr)
VisitPipeline implements RootVisitor.
func (*DepthFirstTraversal) VisitRangeAggregation ¶
func (v *DepthFirstTraversal) VisitRangeAggregation(e *RangeAggregationExpr)
VisitRangeAggregation implements RootVisitor.
func (*DepthFirstTraversal) VisitVector ¶
func (v *DepthFirstTraversal) VisitVector(e *VectorExpr)
VisitVector implements RootVisitor.
func (*DepthFirstTraversal) VisitVectorAggregation ¶
func (v *DepthFirstTraversal) VisitVectorAggregation(e *VectorAggregationExpr)
VisitVectorAggregation implements RootVisitor.
type DropLabelsExpr ¶
type DropLabelsExpr struct {
// contains filtered or unexported fields
}
func (*DropLabelsExpr) Accept ¶
func (e *DropLabelsExpr) Accept(v RootVisitor)
func (*DropLabelsExpr) Pretty ¶
func (e *DropLabelsExpr) Pretty(level int) string
func (*DropLabelsExpr) Shardable ¶
func (e *DropLabelsExpr) Shardable(_ bool) bool
func (*DropLabelsExpr) String ¶
func (e *DropLabelsExpr) String() string
func (*DropLabelsExpr) Walk ¶
func (e *DropLabelsExpr) Walk(f WalkFn)
type Expr ¶
type Expr interface { Shardable(topLevel bool) bool // A recursive check on the AST to see if it's shardable. Walkable fmt.Stringer AcceptVisitor // Pretty prettyfies any LogQL expression at given `level` of the whole LogQL query. Pretty(level int) string // contains filtered or unexported methods }
Expr is the root expression which can be a SampleExpr or LogSelectorExpr
func DecodeJSON ¶
func MustParseExpr ¶
type Grouping ¶
Grouping struct represents the grouping by/without label(s) for vector aggregators and range vector aggregators. The representation is as follows:
- No Grouping (labels dismissed): <operation> (<expr>) => Grouping{Without: false, Groups: nil}
- Grouping by empty label set: <operation> by () (<expr>) => Grouping{Without: false, Groups: []}
- Grouping by label set: <operation> by (<labels...>) (<expr>) => Grouping{Without: false, Groups: [<labels...>]}
- Grouping without empty label set: <operation> without () (<expr>) => Grouping{Without: true, Groups: []}
- Grouping without label set: <operation> without (<labels...>) (<expr>) => Grouping{Without: true, Groups: [<labels...>]}
type JSONExpressionParser ¶
type JSONExpressionParser struct { Expressions []log.LabelExtractionExpr // contains filtered or unexported fields }
func (*JSONExpressionParser) Accept ¶
func (j *JSONExpressionParser) Accept(v RootVisitor)
func (*JSONExpressionParser) Pretty ¶
func (e *JSONExpressionParser) Pretty(level int) string
e.g: | json label="expression", another="expression"
func (*JSONExpressionParser) Shardable ¶
func (j *JSONExpressionParser) Shardable(_ bool) bool
func (*JSONExpressionParser) String ¶
func (j *JSONExpressionParser) String() string
func (*JSONExpressionParser) Walk ¶
func (j *JSONExpressionParser) Walk(f WalkFn)
type JSONSerializer ¶
func NewJSONSerializer ¶
func NewJSONSerializer(s *jsoniter.Stream) *JSONSerializer
func (*JSONSerializer) VisitBinOp ¶
func (v *JSONSerializer) VisitBinOp(e *BinOpExpr)
func (*JSONSerializer) VisitDecolorize ¶
func (*JSONSerializer) VisitDecolorize(*DecolorizeExpr)
Below are StageExpr visitors that we are skipping since a pipeline is serialized as a string.
func (*JSONSerializer) VisitDropLabels ¶
func (*JSONSerializer) VisitDropLabels(*DropLabelsExpr)
func (*JSONSerializer) VisitJSONExpressionParser ¶
func (*JSONSerializer) VisitJSONExpressionParser(*JSONExpressionParser)
func (*JSONSerializer) VisitKeepLabel ¶
func (*JSONSerializer) VisitKeepLabel(*KeepLabelsExpr)
func (*JSONSerializer) VisitLabelFilter ¶
func (*JSONSerializer) VisitLabelFilter(*LabelFilterExpr)
func (*JSONSerializer) VisitLabelFmt ¶
func (*JSONSerializer) VisitLabelFmt(*LabelFmtExpr)
func (*JSONSerializer) VisitLabelParser ¶
func (*JSONSerializer) VisitLabelParser(*LabelParserExpr)
func (*JSONSerializer) VisitLabelReplace ¶
func (v *JSONSerializer) VisitLabelReplace(e *LabelReplaceExpr)
func (*JSONSerializer) VisitLineFilter ¶
func (*JSONSerializer) VisitLineFilter(*LineFilterExpr)
func (*JSONSerializer) VisitLineFmt ¶
func (*JSONSerializer) VisitLineFmt(*LineFmtExpr)
func (*JSONSerializer) VisitLiteral ¶
func (v *JSONSerializer) VisitLiteral(e *LiteralExpr)
func (*JSONSerializer) VisitLogRange ¶
func (v *JSONSerializer) VisitLogRange(e *LogRange)
func (*JSONSerializer) VisitLogfmtExpressionParser ¶
func (*JSONSerializer) VisitLogfmtExpressionParser(*LogfmtExpressionParser)
func (*JSONSerializer) VisitLogfmtParser ¶
func (*JSONSerializer) VisitLogfmtParser(*LogfmtParserExpr)
func (*JSONSerializer) VisitMatchers ¶
func (v *JSONSerializer) VisitMatchers(e *MatchersExpr)
func (*JSONSerializer) VisitPipeline ¶
func (v *JSONSerializer) VisitPipeline(e *PipelineExpr)
func (*JSONSerializer) VisitRangeAggregation ¶
func (v *JSONSerializer) VisitRangeAggregation(e *RangeAggregationExpr)
func (*JSONSerializer) VisitVector ¶
func (v *JSONSerializer) VisitVector(e *VectorExpr)
func (*JSONSerializer) VisitVectorAggregation ¶
func (v *JSONSerializer) VisitVectorAggregation(e *VectorAggregationExpr)
type KeepLabelsExpr ¶
type KeepLabelsExpr struct {
// contains filtered or unexported fields
}
func (*KeepLabelsExpr) Accept ¶
func (e *KeepLabelsExpr) Accept(v RootVisitor)
func (*KeepLabelsExpr) Pretty ¶
func (e *KeepLabelsExpr) Pretty(level int) string
func (*KeepLabelsExpr) Shardable ¶
func (e *KeepLabelsExpr) Shardable(_ bool) bool
func (*KeepLabelsExpr) String ¶
func (e *KeepLabelsExpr) String() string
func (*KeepLabelsExpr) Walk ¶
func (e *KeepLabelsExpr) Walk(f WalkFn)
type LabelFilterExpr ¶
type LabelFilterExpr struct { log.LabelFilterer // contains filtered or unexported fields }
func ExtractLabelFiltersBeforeParser ¶
func ExtractLabelFiltersBeforeParser(e Expr) []*LabelFilterExpr
func (*LabelFilterExpr) Accept ¶
func (e *LabelFilterExpr) Accept(v RootVisitor)
func (*LabelFilterExpr) Pretty ¶
func (e *LabelFilterExpr) Pretty(level int) string
e.g: | level!="error"
func (*LabelFilterExpr) Shardable ¶
func (e *LabelFilterExpr) Shardable(_ bool) bool
func (*LabelFilterExpr) String ¶
func (e *LabelFilterExpr) String() string
func (*LabelFilterExpr) Walk ¶
func (e *LabelFilterExpr) Walk(f WalkFn)
type LabelFmtExpr ¶
func (*LabelFmtExpr) Accept ¶
func (e *LabelFmtExpr) Accept(v RootVisitor)
func (*LabelFmtExpr) Pretty ¶
func (e *LabelFmtExpr) Pretty(level int) string
e.g: | label_format dst="{{ .src }}"
func (*LabelFmtExpr) Shardable ¶
func (e *LabelFmtExpr) Shardable(_ bool) bool
func (*LabelFmtExpr) String ¶
func (e *LabelFmtExpr) String() string
func (*LabelFmtExpr) Walk ¶
func (e *LabelFmtExpr) Walk(f WalkFn)
type LabelParserExpr ¶
func (*LabelParserExpr) Accept ¶
func (e *LabelParserExpr) Accept(v RootVisitor)
func (*LabelParserExpr) Pretty ¶
func (e *LabelParserExpr) Pretty(level int) string
e.g: `| json` `| regexp` `| pattern` `| unpack`
func (*LabelParserExpr) Shardable ¶
func (e *LabelParserExpr) Shardable(_ bool) 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) Accept ¶
func (e *LabelReplaceExpr) Accept(v RootVisitor)
func (*LabelReplaceExpr) Extractor ¶
func (e *LabelReplaceExpr) Extractor() (SampleExtractor, error)
func (*LabelReplaceExpr) MatcherGroups ¶
func (e *LabelReplaceExpr) MatcherGroups() ([]MatcherRange, error)
func (*LabelReplaceExpr) Pretty ¶
func (e *LabelReplaceExpr) Pretty(level int) string
e.g: label_replace(rate({job="api-server",service="a:c"}[5m]), "foo", "$1", "service", "(.*):.*")
func (*LabelReplaceExpr) Selector ¶
func (e *LabelReplaceExpr) Selector() (LogSelectorExpr, error)
func (*LabelReplaceExpr) Shardable ¶
func (e *LabelReplaceExpr) Shardable(_ bool) bool
func (*LabelReplaceExpr) String ¶
func (e *LabelReplaceExpr) String() string
func (*LabelReplaceExpr) Walk ¶
func (e *LabelReplaceExpr) Walk(f WalkFn)
type LineFilter ¶
type LineFilter struct { Ty log.LineMatchType Match string Op string }
func (LineFilter) Equal ¶
func (lf LineFilter) Equal(o LineFilter) bool
func (LineFilter) Size ¶
func (lf LineFilter) Size() int
func (*LineFilter) Unmarshal ¶
func (lf *LineFilter) Unmarshal(b []byte) error
type LineFilterExpr ¶
type LineFilterExpr struct { LineFilter Left *LineFilterExpr // See LineFilterExpr tests for more examples. Or *LineFilterExpr IsOrChild bool // contains filtered or unexported fields }
func ExtractLineFilters ¶
func ExtractLineFilters(e Expr) []LineFilterExpr
func (*LineFilterExpr) Accept ¶
func (e *LineFilterExpr) Accept(v RootVisitor)
func (*LineFilterExpr) Pretty ¶
func (e *LineFilterExpr) Pretty(level int) string
e.g: `|= "error" != "memcache" |= ip("192.168.0.1")` NOTE: here `ip` is Op in this expression.
func (*LineFilterExpr) Shardable ¶
func (e *LineFilterExpr) Shardable(_ bool) 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) Accept ¶
func (e *LineFmtExpr) Accept(v RootVisitor)
func (*LineFmtExpr) Pretty ¶
func (e *LineFmtExpr) Pretty(level int) string
e.g: | line_format "{{ .label }}"
func (*LineFmtExpr) Shardable ¶
func (e *LineFmtExpr) Shardable(_ bool) 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 `json:"val"` // contains filtered or unexported fields }
func (*LiteralExpr) Accept ¶
func (e *LiteralExpr) Accept(v RootVisitor)
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, error)
func (*LiteralExpr) Matchers ¶
func (e *LiteralExpr) Matchers() []*labels.Matcher
func (*LiteralExpr) Selector ¶
func (e *LiteralExpr) Selector() (LogSelectorExpr, error)
func (*LiteralExpr) Shardable ¶
func (e *LiteralExpr) Shardable(_ bool) bool
func (*LiteralExpr) String ¶
func (e *LiteralExpr) String() string
func (*LiteralExpr) Value ¶
func (e *LiteralExpr) Value() (float64, error)
func (*LiteralExpr) Walk ¶
func (e *LiteralExpr) Walk(f WalkFn)
type LogRange ¶
type LogRange struct { Left LogSelectorExpr Interval time.Duration Offset time.Duration Unwrap *UnwrapExpr // contains filtered or unexported fields }
func (*LogRange) Accept ¶
func (r *LogRange) Accept(v RootVisitor)
func (*LogRange) Pretty ¶
e.g: `{foo="bar"}|logfmt[5m]` TODO(kavi): Rename `LogRange` -> `LogRangeExpr` (to be consistent with other expressions?)
func (*LogRange) WithoutUnwrap ¶
WithoutUnwrap returns a copy of the log range without the unwrap statement.
type LogSelectorExpr ¶
type LogSelectorExpr interface { Matchers() []*labels.Matcher Pipeline() (Pipeline, error) HasFilter() bool Expr // contains filtered or unexported methods }
LogSelectorExpr is a LogQL expression filtering and returning logs.
func AddFilterExpr ¶
func AddFilterExpr(expr LogSelectorExpr, ty log.LineMatchType, 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 LogSelectorExprVisitor ¶
type LogSelectorExprVisitor interface { VisitMatchers(*MatchersExpr) VisitPipeline(*PipelineExpr) VisitLiteral(*LiteralExpr) VisitVector(*VectorExpr) }
type LogfmtExpressionParser ¶
type LogfmtExpressionParser struct { Expressions []log.LabelExtractionExpr Strict, KeepEmpty bool // contains filtered or unexported fields }
func (*LogfmtExpressionParser) Accept ¶
func (l *LogfmtExpressionParser) Accept(v RootVisitor)
func (*LogfmtExpressionParser) Pretty ¶
func (e *LogfmtExpressionParser) Pretty(level int) string
e.g: | logfmt label="expression", another="expression"
func (*LogfmtExpressionParser) Shardable ¶
func (l *LogfmtExpressionParser) Shardable(_ bool) bool
func (*LogfmtExpressionParser) String ¶
func (l *LogfmtExpressionParser) String() string
func (*LogfmtExpressionParser) Walk ¶
func (l *LogfmtExpressionParser) Walk(f WalkFn)
type LogfmtParserExpr ¶
type LogfmtParserExpr struct { Strict bool KeepEmpty bool // contains filtered or unexported fields }
func (*LogfmtParserExpr) Accept ¶
func (e *LogfmtParserExpr) Accept(v RootVisitor)
func (*LogfmtParserExpr) Pretty ¶
func (e *LogfmtParserExpr) Pretty(level int) string
func (*LogfmtParserExpr) Shardable ¶
func (e *LogfmtParserExpr) Shardable(_ bool) bool
func (*LogfmtParserExpr) String ¶
func (e *LogfmtParserExpr) String() string
func (*LogfmtParserExpr) Walk ¶
func (e *LogfmtParserExpr) Walk(f WalkFn)
type MatcherRange ¶
func MatcherGroups ¶
func MatcherGroups(expr Expr) ([]MatcherRange, error)
type MatchersExpr ¶
func (*MatchersExpr) Accept ¶
func (e *MatchersExpr) Accept(v RootVisitor)
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) 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 implements a LogSelectorExpr.
func (MultiStageExpr) String ¶
func (m MultiStageExpr) String() string
type OffsetExpr ¶
func (*OffsetExpr) Pretty ¶
func (e *OffsetExpr) Pretty(_ int) string
e.g: count_over_time({foo="bar"}[5m] offset 3h) TODO(kavi): why does offset not work in log queries? e.g: `{foo="bar"} offset 1h`? is it bug? or anything else? NOTE: Also offset expression never to be indented. It always goes with its parent expression (usually RangeExpr).
func (*OffsetExpr) String ¶
func (o *OffsetExpr) String() string
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
ParseError is what is returned when we failed to parse.
func NewParseError ¶
func NewParseError(msg string, line, col int) ParseError
func NewStageError ¶
func NewStageError(expr string, err error) ParseError
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 PipelineError ¶
type PipelineError struct {
// contains filtered or unexported fields
}
func NewPipelineErr ¶
func NewPipelineErr(metric labels.Labels) *PipelineError
func (PipelineError) Error ¶
func (e PipelineError) Error() string
func (PipelineError) Is ¶
func (e PipelineError) Is(target error) bool
Is allows to use errors.Is(err,ErrPipeline) on this error.
type PipelineExpr ¶
type PipelineExpr struct { MultiStages MultiStageExpr Left *MatchersExpr // contains filtered or unexported fields }
func (*PipelineExpr) Accept ¶
func (e *PipelineExpr) Accept(v RootVisitor)
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) Pretty ¶
func (e *PipelineExpr) Pretty(level int) string
e.g: `{foo="bar"} | logfmt | level="error"` Here, left = `{foo="bar"}` and multistages would collection of each stage in pipeline, here `logfmt` and `level="error"`
func (*PipelineExpr) Shardable ¶
func (e *PipelineExpr) Shardable(topLevel bool) bool
func (*PipelineExpr) String ¶
func (e *PipelineExpr) String() string
func (*PipelineExpr) Walk ¶
func (e *PipelineExpr) Walk(f WalkFn)
type Position ¶
type Position struct { Filename string // filename, if any Offset int // byte offset, starting at 0 Line int // line number, starting at 1 Column int // column number, starting at 1 (character count per line) }
Position is a value that represents a source position. A position is valid if Line > 0.
type RangeAggregationExpr ¶
type RangeAggregationExpr struct { Left *LogRange Operation string Params *float64 Grouping *Grouping // contains filtered or unexported fields }
RangeAggregationExpr not all range vector aggregation expressions support grouping by/without label(s), therefore the Grouping struct can be nil.
func (*RangeAggregationExpr) Accept ¶
func (e *RangeAggregationExpr) Accept(v RootVisitor)
func (RangeAggregationExpr) Extractor ¶
func (r RangeAggregationExpr) Extractor() (log.SampleExtractor, error)
func (*RangeAggregationExpr) MatcherGroups ¶
func (e *RangeAggregationExpr) MatcherGroups() ([]MatcherRange, error)
func (*RangeAggregationExpr) Pretty ¶
func (e *RangeAggregationExpr) Pretty(level int) string
e.g: count_over_time({foo="bar"}[5m])
func (*RangeAggregationExpr) Selector ¶
func (e *RangeAggregationExpr) Selector() (LogSelectorExpr, error)
func (*RangeAggregationExpr) Shardable ¶
func (e *RangeAggregationExpr) Shardable(topLevel bool) bool
impl SampleExpr
func (RangeAggregationExpr) Validate ¶
func (e RangeAggregationExpr) Validate() error
func (*RangeAggregationExpr) Walk ¶
func (e *RangeAggregationExpr) Walk(f WalkFn)
type RootVisitor ¶
type RootVisitor interface { SampleExprVisitor LogSelectorExprVisitor StageExprVisitor VisitLogRange(*LogRange) }
type SampleExpr ¶
type SampleExpr interface { // Selector is the LogQL selector to apply when retrieving logs. Selector() (LogSelectorExpr, error) Extractor() (SampleExtractor, error) MatcherGroups() ([]MatcherRange, error) Expr // contains filtered or unexported methods }
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 SampleExprVisitor ¶
type SampleExprVisitor interface { VisitBinOp(*BinOpExpr) VisitVectorAggregation(*VectorAggregationExpr) VisitRangeAggregation(*RangeAggregationExpr) VisitLabelReplace(*LabelReplaceExpr) VisitLiteral(*LiteralExpr) VisitVector(*VectorExpr) }
type SampleExtractor ¶
type SampleExtractor = log.SampleExtractor
Type alias for backward compatibility
type Scanner ¶
type Scanner struct { // Error is called for each error encountered. If no Error // function is set, the error is reported to os.Stderr. Error func(s *Scanner, msg string) // ErrorCount is incremented by one for each error encountered. ErrorCount int // The Mode field controls which tokens are recognized. For instance, // to recognize Ints, set the ScanInts bit in Mode. The field may be // changed at any time. Mode uint // The Whitespace field controls which characters are recognized // as white space. To recognize a character ch <= ' ' as white space, // set the ch'th bit in Whitespace (the Scanner's behavior is undefined // for values ch > ' '). The field may be changed at any time. Whitespace uint64 // IsIdentRune is a predicate controlling the characters accepted // as the ith rune in an identifier. The set of valid characters // must not intersect with the set of white space characters. // If no IsIdentRune function is set, regular Go identifiers are // accepted instead. The field may be changed at any time. IsIdentRune func(ch rune, i int) bool // Start position of most recently scanned token; set by Scan. // Calling Init or Next invalidates the position (Line == 0). // The Filename field is always left untouched by the Scanner. // If an error is reported (via Error) and Position is invalid, // the scanner is not inside a token. Call Pos to obtain an error // position in that case, or to obtain the position immediately // after the most recently scanned token. Position // contains filtered or unexported fields }
A Scanner implements reading of Unicode characters and tokens from an io.Reader.
func (*Scanner) Init ¶
Init initializes a Scanner with a new source and returns s. Error is set to nil, ErrorCount is set to 0, Mode is set to GoTokens, and Whitespace is set to GoWhitespace.
func (*Scanner) Next ¶
Next reads and returns the next Unicode character. It returns EOF at the end of the source. It reports a read error by calling s.Error, if not nil; otherwise it prints an error message to os.Stderr. Next does not update the Scanner's Position field; use Pos() to get the current position.
func (*Scanner) Peek ¶
Peek returns the next Unicode character in the source without advancing the scanner. It returns EOF if the scanner's position is at the last character of the source.
func (*Scanner) Pos ¶
Pos returns the position of the character immediately after the character or token returned by the last call to Next or Scan. Use the Scanner's Position field for the start position of the most recently scanned token.
func (*Scanner) Scan ¶
Scan reads the next token or Unicode character from source and returns it. It only recognizes tokens t for which the respective Mode bit (1<<-t) is set. It returns EOF at the end of the source. It reports scanner errors (read and token errors) by calling s.Error, if not nil; otherwise it prints an error message to os.Stderr.
type StageExpr ¶
type StageExpr interface { Stage() (log.Stage, error) Expr // contains filtered or unexported methods }
StageExpr is an expression defining a single step into a log pipeline
type StageExprVisitor ¶
type StageExprVisitor interface { VisitDecolorize(*DecolorizeExpr) VisitDropLabels(*DropLabelsExpr) VisitJSONExpressionParser(*JSONExpressionParser) VisitKeepLabel(*KeepLabelsExpr) VisitLabelFilter(*LabelFilterExpr) VisitLabelFmt(*LabelFmtExpr) VisitLabelParser(*LabelParserExpr) VisitLineFilter(*LineFilterExpr) VisitLineFmt(*LineFmtExpr) VisitLogfmtExpressionParser(*LogfmtExpressionParser) VisitLogfmtParser(*LogfmtParserExpr) }
type UnwrapExpr ¶
type UnwrapExpr struct { Identifier string Operation string PostFilters []log.LabelFilterer }
func (*UnwrapExpr) Pretty ¶
func (e *UnwrapExpr) Pretty(level int) string
e.g: sum_over_time({foo="bar"} | logfmt | unwrap bytes_processed [5m])
func (UnwrapExpr) String ¶
func (u UnwrapExpr) String() string
type VectorAggregationExpr ¶
type VectorAggregationExpr struct { Left SampleExpr `json:"sample_expr"` Grouping *Grouping `json:"grouping,omitempty"` Params int `json:"params"` Operation string `json:"operation"` // contains filtered or unexported fields }
VectorAggregationExpr all vector aggregation expressions support grouping by/without label(s), therefore the Grouping struct can never be nil.
func (*VectorAggregationExpr) Accept ¶
func (e *VectorAggregationExpr) Accept(v RootVisitor)
func (*VectorAggregationExpr) Extractor ¶
func (e *VectorAggregationExpr) Extractor() (log.SampleExtractor, error)
func (*VectorAggregationExpr) MatcherGroups ¶
func (e *VectorAggregationExpr) MatcherGroups() ([]MatcherRange, error)
func (*VectorAggregationExpr) Pretty ¶
func (e *VectorAggregationExpr) Pretty(level int) string
Syntax: <aggr-op>([parameter,] <vector expression>) [without|by (<label list>)] <aggr-op> - sum, avg, bottomk, topk, etc. [parameters,] - optional params, used only by bottomk and topk for now. <vector expression> - vector on which aggregation is done. [without|by (<label list)] - optional labels to aggregate either with `by` or `without` clause.
func (*VectorAggregationExpr) Selector ¶
func (e *VectorAggregationExpr) Selector() (LogSelectorExpr, error)
func (*VectorAggregationExpr) Shardable ¶
func (e *VectorAggregationExpr) Shardable(topLevel bool) bool
impl SampleExpr
func (*VectorAggregationExpr) String ¶
func (e *VectorAggregationExpr) String() string
func (*VectorAggregationExpr) Walk ¶
func (e *VectorAggregationExpr) Walk(f WalkFn)
type VectorExpr ¶
type VectorExpr struct { Val float64 // contains filtered or unexported fields }
func NewVectorExpr ¶
func NewVectorExpr(scalar string) *VectorExpr
func (*VectorExpr) Accept ¶
func (e *VectorExpr) Accept(v RootVisitor)
func (*VectorExpr) Err ¶
func (e *VectorExpr) Err() error
func (*VectorExpr) Extractor ¶
func (e *VectorExpr) Extractor() (log.SampleExtractor, error)
func (*VectorExpr) HasFilter ¶
func (e *VectorExpr) HasFilter() bool
func (*VectorExpr) MatcherGroups ¶
func (e *VectorExpr) MatcherGroups() ([]MatcherRange, error)
func (*VectorExpr) Matchers ¶
func (e *VectorExpr) Matchers() []*labels.Matcher
func (*VectorExpr) Selector ¶
func (e *VectorExpr) Selector() (LogSelectorExpr, error)
func (*VectorExpr) Shardable ¶
func (e *VectorExpr) Shardable(_ bool) bool
func (*VectorExpr) String ¶
func (e *VectorExpr) String() string
func (*VectorExpr) Value ¶
func (e *VectorExpr) Value() (float64, error)
func (*VectorExpr) Walk ¶
func (e *VectorExpr) 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.