syntax

package
v2.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2022 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const ABSENT_OVER_TIME = 57403
View Source
const ADD = 57422
View Source
const AND = 57414
View Source
const AVG = 57373
View Source
const AVG_OVER_TIME = 57391
View Source
const BOOL = 57383
View Source
const BOTTOMK = 57379
View Source
const BY = 57367
View Source
const BYTES = 57346
View Source
const BYTES_CONV = 57398
View Source
const BYTES_OVER_TIME = 57381
View Source
const BYTES_RATE = 57382
View Source
const CLOSE_BRACE = 57358
View Source
const CLOSE_BRACKET = 57360
View Source
const CLOSE_PARENTHESIS = 57366
View Source
const CMP_EQ = 57416
View Source
const COMMA = 57361
View Source
const COUNT = 57376
View Source
const COUNT_OVER_TIME = 57369
View Source
const DIV = 57425
View Source
const DOT = 57362
View Source
const DURATION = 57350
View Source
const DURATION_CONV = 57399
View Source
const DURATION_SECONDS_CONV = 57400
View Source
const EQ = 57354
View Source
const (
	EmptyMatchers = "{}"
)
View Source
const FIRST_OVER_TIME = 57401
View Source
const GROUP_LEFT = 57411
View Source
const GROUP_RIGHT = 57412
View Source
const GT = 57420
View Source
const GTE = 57421
View Source
const IDENTIFIER = 57347
View Source
const IGNORING = 57410
View Source
const IP = 57408
View Source
const JSON = 57384
View Source
const LABELS = 57353
View Source
const LABEL_FMT = 57389
View Source
const LABEL_REPLACE = 57404
View Source
const LAST_OVER_TIME = 57402
View Source
const LINE_FMT = 57388
View Source
const LOGFMT = 57386
View Source
const LT = 57418
View Source
const LTE = 57419
View Source
const MATCHERS = 57352
View Source
const MAX = 57374
View Source
const MAX_OVER_TIME = 57394
View Source
const MIN = 57375
View Source
const MIN_OVER_TIME = 57393
View Source
const MOD = 57426
View Source
const MUL = 57424
View Source
const NEQ = 57417
View Source
const NRE = 57356
View Source
const NUMBER = 57349
View Source
const OFFSET = 57406
View Source
const ON = 57409
View Source
const OPEN_BRACE = 57357
View Source
const OPEN_BRACKET = 57359
View Source
const OPEN_PARENTHESIS = 57365
View Source
const OR = 57413
View Source
const PATTERN = 57407
View Source
const PIPE = 57387
View Source
const PIPE_EXACT = 57364
View Source
const PIPE_MATCH = 57363
View Source
const POW = 57427
View Source
const QUANTILE_OVER_TIME = 57397
View Source
const RANGE = 57351
View Source
const RATE = 57370
View Source
const RATE_COUNTER = 57371
View Source
const RE = 57355
View Source
const REGEXP = 57385
View Source
const STDDEV = 57377
View Source
const STDDEV_OVER_TIME = 57396
View Source
const STDVAR = 57378
View Source
const STDVAR_OVER_TIME = 57395
View Source
const STRING = 57348
View Source
const SUB = 57423
View Source
const SUM = 57372
View Source
const SUM_OVER_TIME = 57392
View Source
const TOPK = 57380
View Source
const UNLESS = 57415
View Source
const UNPACK = 57405
View Source
const UNWRAP = 57390
View Source
const UnsupportedErr = "unsupported range vector aggregation operation: %s"
View Source
const WITHOUT = 57368

Variables

This section is empty.

Functions

func IsComparisonOperator

func IsComparisonOperator(op string) bool

func IsLogicalBinOp

func IsLogicalBinOp(op string) bool

IsLogicalBinOp tests whether an operation is a logical/set binary operation

func MatchersString

func MatchersString(xs []*labels.Matcher) string

func MergeBinOp

func MergeBinOp(op string, left, right *promql.Sample, filter, isVectorComparison bool) *promql.Sample

func ParseLabels

func ParseLabels(lbs string) (labels.Labels, error)

ParseLabels parses labels from a string using logql parser.

func ParseMatchers

func ParseMatchers(input string) ([]*labels.Matcher, error)

ParseMatchers parses a string and returns labels matchers, if the expression contains anything else it will return an error.

Types

type BinOpExpr

type BinOpExpr struct {
	SampleExpr
	RHS  SampleExpr
	Op   string
	Opts *BinOpOptions
}

func (*BinOpExpr) MatcherGroups

func (e *BinOpExpr) MatcherGroups() []MatcherRange

func (*BinOpExpr) Shardable

func (e *BinOpExpr) Shardable() bool

impl SampleExpr

func (*BinOpExpr) String

func (e *BinOpExpr) String() string

func (*BinOpExpr) Walk

func (e *BinOpExpr) Walk(f WalkFn)

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

func Clone

func Clone(e Expr) (Expr, error)

func ParseExpr

func ParseExpr(input string) (Expr, error)

ParseExpr parses a string and returns an Expr.

type Grouping

type Grouping struct {
	Groups  []string
	Without bool
}

func (Grouping) String

func (g Grouping) String() string

impls Stringer

type JSONExpressionParser

type JSONExpressionParser struct {
	Expressions []log.JSONExpression
	// contains filtered or unexported fields
}

func (*JSONExpressionParser) Shardable

func (j *JSONExpressionParser) Shardable() bool

func (*JSONExpressionParser) Stage

func (j *JSONExpressionParser) Stage() (log.Stage, error)

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) Stage

func (e *LabelFilterExpr) Stage() (log.Stage, error)

func (*LabelFilterExpr) String

func (e *LabelFilterExpr) String() string

func (*LabelFilterExpr) Walk

func (e *LabelFilterExpr) Walk(f WalkFn)

type LabelFmtExpr

type LabelFmtExpr struct {
	Formats []log.LabelFmt
	// contains filtered or unexported fields
}

func (*LabelFmtExpr) Shardable

func (e *LabelFmtExpr) Shardable() bool

func (*LabelFmtExpr) Stage

func (e *LabelFmtExpr) Stage() (log.Stage, error)

func (*LabelFmtExpr) String

func (e *LabelFmtExpr) String() string

func (*LabelFmtExpr) Walk

func (e *LabelFmtExpr) Walk(f WalkFn)

type LabelParserExpr

type LabelParserExpr struct {
	Op    string
	Param string
	// contains filtered or unexported fields
}

func (*LabelParserExpr) Shardable

func (e *LabelParserExpr) Shardable() bool

func (*LabelParserExpr) Stage

func (e *LabelParserExpr) Stage() (log.Stage, error)

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) Filter

func (e *LineFilterExpr) Filter() (log.Filterer, error)

func (*LineFilterExpr) Shardable

func (e *LineFilterExpr) Shardable() bool

func (*LineFilterExpr) Stage

func (e *LineFilterExpr) Stage() (log.Stage, error)

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) Stage

func (e *LineFmtExpr) Stage() (log.Stage, error)

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) Pipeline

func (e *LiteralExpr) Pipeline() (log.Pipeline, error)

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

type LogPipelineExpr interface {
	Pipeline() (Pipeline, error)
	Expr
}

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
}

func (*LogRange) Shardable

func (r *LogRange) Shardable() bool

func (LogRange) String

func (r LogRange) String() string

impls Stringer

func (*LogRange) Walk

func (r *LogRange) Walk(f WalkFn)

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

type MatcherRange struct {
	Matchers         []*labels.Matcher
	Interval, Offset time.Duration
}

func MatcherGroups

func MatcherGroups(expr Expr) []MatcherRange

type MatchersExpr

type MatchersExpr struct {
	Mts []*labels.Matcher
	// contains filtered or unexported fields
}

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) Pipeline

func (e *MatchersExpr) Pipeline() (log.Pipeline, error)

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) Pipeline

func (m MultiStageExpr) Pipeline() (log.Pipeline, error)

func (MultiStageExpr) String

func (m MultiStageExpr) String() string

type OffsetExpr

type OffsetExpr struct {
	Offset time.Duration
}

func (*OffsetExpr) String

func (o *OffsetExpr) String() string

type Pipeline

type Pipeline = log.Pipeline

Type alias for backward compatibility

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) Pipeline

func (e *PipelineExpr) Pipeline() (log.Pipeline, error)

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) String

func (e *RangeAggregationExpr) String() string

impls Stringer

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 StageExpr

type StageExpr interface {
	Stage() (log.Stage, error)
	Expr
}

StageExpr is an expression defining a single step into a log pipeline

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.

type WalkFn

type WalkFn = func(e interface{})

type Walkable

type Walkable interface {
	Walk(f WalkFn)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL