logql

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpTypeSum           = "sum"
	OpTypeAvg           = "avg"
	OpTypeMax           = "max"
	OpTypeMin           = "min"
	OpTypeCount         = "count"
	OpTypeStddev        = "stddev"
	OpTypeStdvar        = "stdvar"
	OpTypeBottomK       = "bottomk"
	OpTypeTopK          = "topk"
	OpTypeCountOverTime = "count_over_time"
	OpTypeRate          = "rate"
)
View Source
const AVG = 57371
View Source
const BOTTOMK = 57377
View Source
const BY = 57366
View Source
const CLOSE_BRACE = 57356
View Source
const CLOSE_BRACKET = 57358
View Source
const CLOSE_PARENTHESIS = 57365
View Source
const COMMA = 57359
View Source
const COUNT = 57374
View Source
const COUNT_OVER_TIME = 57368
View Source
const DOT = 57360
View Source
const DURATION = 57348
View Source
const EQ = 57351
View Source
const IDENTIFIER = 57346
View Source
const LABELS = 57350
View Source
const MATCHERS = 57349
View Source
const MAX = 57372
View Source
const MIN = 57373
View Source
const NEQ = 57352
View Source
const NRE = 57354
View Source
const OPEN_BRACE = 57355
View Source
const OPEN_BRACKET = 57357
View Source
const OPEN_PARENTHESIS = 57364
View Source
const PIPE_EXACT = 57362
View Source
const PIPE_MATCH = 57361
View Source
const RATE = 57369
View Source
const RE = 57353
View Source
const SLASH = 57363
View Source
const STDDEV = 57375
View Source
const STDVAR = 57376
View Source
const STRING = 57347
View Source
const SUM = 57370
View Source
const TOPK = 57378
View Source
const ValueTypeStreams = "streams"

ValueTypeStreams promql.ValueType for log streams

View Source
const WITHOUT = 57367

Variables

This section is empty.

Functions

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 Engine added in v0.4.0

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the LogQL engine.

func NewEngine added in v0.4.0

func NewEngine(opts EngineOpts) *Engine

NewEngine creates a new LogQL engine.

func (*Engine) NewInstantQuery added in v0.4.0

func (ng *Engine) NewInstantQuery(
	q Querier,
	qs string,
	ts time.Time,
	direction logproto.Direction, limit uint32) Query

NewInstantQuery creates a new LogQL instant query.

func (*Engine) NewRangeQuery added in v0.4.0

func (ng *Engine) NewRangeQuery(
	q Querier,
	qs string,
	start, end time.Time, step time.Duration,
	direction logproto.Direction, limit uint32) Query

NewRangeQuery creates a new LogQL range query.

type EngineOpts added in v0.4.0

type EngineOpts struct {
	// Timeout for queries execution
	Timeout time.Duration `yaml:"timeout"`
	// MaxLookBackPeriod is the maximun amount of time to look back for log lines.
	// only used for instant log queries.
	MaxLookBackPeriod time.Duration `yaml:"max_look_back_period"`
}

EngineOpts is the list of options to use with the LogQL query engine.

type Expr

type Expr interface{}

Expr is the root expression which can be a SampleExpr or LogSelectorExpr

func ParseExpr

func ParseExpr(input string) (expr Expr, err error)

ParseExpr parses a string and returns an Expr.

type Filter added in v0.2.0

type Filter func(line []byte) bool

Filter is a function to filter logs.

type LogSelectorExpr added in v0.4.0

type LogSelectorExpr interface {
	Tags() ([]*TagMatcher, []Filter)
	Filter() (Filter, error)
	Matchers() []*labels.Matcher
	fmt.Stringer
}

LogSelectorExpr is a LogQL expression filtering and returning logs.

func NewFilterExpr

func NewFilterExpr(left LogSelectorExpr, ty labels.MatchType, match string) LogSelectorExpr

NewFilterExpr wraps an existing Expr with a next filter expression.

func ParseLogSelector added in v0.4.0

func ParseLogSelector(input string) (LogSelectorExpr, error)

ParseLogSelector parses a log selector expression `{app="foo"} |= "filter"`

type ParseError

type ParseError struct {
	// contains filtered or unexported fields
}

ParseError is what is returned when we failed to parse.

func (ParseError) Error

func (p ParseError) Error() string

type Querier

type Querier interface {
	Select(context.Context, SelectParams) (iter.EntryIterator, error)
}

Querier allows a LogQL expression to fetch an EntryIterator for a set of matchers and filters

type QuerierFunc

type QuerierFunc func(context.Context, SelectParams) (iter.EntryIterator, error)

QuerierFunc implements Querier.

func (QuerierFunc) Select added in v0.4.0

Select implements Querier.

type Query added in v0.4.0

type Query interface {
	// Exec processes the query.
	Exec(ctx context.Context) (promql.Value, error)
}

Query is a LogQL query to be executed.

type RangeVectorAggregator added in v0.4.0

type RangeVectorAggregator func(int64, []promql.Point) float64

RangeVectorAggregator aggregates samples for a given range of samples. It receives the current milliseconds timestamp and the list of point within the range.

type RangeVectorIterator added in v0.4.0

type RangeVectorIterator interface {
	Next() bool
	At(aggregator RangeVectorAggregator) (int64, promql.Vector)
	Close() error
}

RangeVectorIterator iterates through a range of samples. To fetch the current vector use `At` with a `RangeVectorAggregator`.

type SampleExpr added in v0.4.0

type SampleExpr interface {
	// Selector is the LogQL selector to apply when retrieving logs.
	Selector() LogSelectorExpr
	// Evaluator returns a `StepEvaluator` that can evaluate the expression step by step
	Evaluator() StepEvaluator
	// Close all resources used.
	Close() error
}

SampleExpr is a LogQL expression filtering logs and returning metric samples.

type SelectParams added in v0.4.0

type SelectParams struct {
	*logproto.QueryRequest
}

SelectParams specifies parameters passed to data selections.

func (SelectParams) LogSelector added in v0.4.0

func (s SelectParams) LogSelector() (LogSelectorExpr, error)

LogSelector returns the LogSelectorExpr from the SelectParams. The `LogSelectorExpr` can then returns all matchers and filters to use for that request.

type StepEvaluator added in v0.4.0

type StepEvaluator interface {
	Next() (bool, int64, promql.Vector)
}

StepEvaluator evaluate a single step of a query.

type StepEvaluatorFn added in v0.4.0

type StepEvaluatorFn func() (bool, int64, promql.Vector)

StepEvaluatorFn is a function to chain multiple `StepEvaluator`.

func (StepEvaluatorFn) Next added in v0.4.0

func (s StepEvaluatorFn) Next() (bool, int64, promql.Vector)

Next implements `StepEvaluator`

type Streams added in v0.4.0

type Streams []*logproto.Stream

Streams is promql.Value

func (Streams) String added in v0.4.0

func (Streams) String() string

String implements `promql.Value`

func (Streams) Type added in v0.4.0

func (Streams) Type() promql.ValueType

Type implements `promql.Value`

type TagMatcher added in v0.4.0

type TagMatcher struct {
	Name  string
	Value string
}

Tag represents a high-cardinality KV label. It does not participate the computation of the streamID, so it will not affect the granularity of the aggregation of chunks.

Tag will store a different index entry, it points to the chunk which contains the log line which has the tag.

When performing a query, tag will be used to determine which chunk to look at, and it will return a Filter func just like any other Filter. And you should use it to filter the lines within that chunk.

func (*TagMatcher) String added in v0.4.0

func (t *TagMatcher) String() string

Directories

Path Synopsis
Package marshal converts internal objects to loghttp model objects.
Package marshal converts internal objects to loghttp model objects.
legacy
Package marshal converts internal objects to loghttp model objects.
Package marshal converts internal objects to loghttp model objects.

Jump to

Keyboard shortcuts

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