Documentation
¶
Index ¶
- Constants
- func ParseMatchers(input string) ([]*labels.Matcher, error)
- type Engine
- type EngineOpts
- type Expr
- type Filter
- type LogSelectorExpr
- type ParseError
- type Querier
- type QuerierFunc
- type Query
- type RangeVectorAggregator
- type RangeVectorIterator
- type SampleExpr
- type SelectParams
- type StepEvaluator
- type StepEvaluatorFn
- type Streams
Constants ¶
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"
)
const AVG = 57370
const BOTTOMK = 57376
const BY = 57365
const CLOSE_BRACE = 57356
const CLOSE_BRACKET = 57358
const CLOSE_PARENTHESIS = 57364
const COMMA = 57359
const COUNT = 57373
const COUNT_OVER_TIME = 57367
const DOT = 57360
const DURATION = 57348
const EQ = 57351
const IDENTIFIER = 57346
const LABELS = 57350
const MATCHERS = 57349
const MAX = 57371
const MIN = 57372
const NEQ = 57352
const NRE = 57354
const OPEN_BRACE = 57355
const OPEN_BRACKET = 57357
const OPEN_PARENTHESIS = 57363
const PIPE_EXACT = 57362
const PIPE_MATCH = 57361
const RATE = 57368
const RE = 57353
const STDDEV = 57374
const STDVAR = 57375
const STRING = 57347
const SUM = 57369
const TOPK = 57377
const ValueTypeStreams = "streams"
ValueTypeStreams promql.ValueType for log streams
const WITHOUT = 57366
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 v1.0.1
type Engine struct {
// contains filtered or unexported fields
}
Engine is the LogQL engine.
func NewEngine ¶ added in v1.0.1
func NewEngine(opts EngineOpts) *Engine
NewEngine creates a new LogQL engine.
func (*Engine) NewInstantQuery ¶ added in v1.0.1
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 v1.0.1
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 v1.0.1
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
type Filter ¶ added in v1.0.1
type Filter func(line []byte) bool
Filter is a function to filter logs.
type LogSelectorExpr ¶ added in v1.0.1
type LogSelectorExpr interface {
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 v1.0.1
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.
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.
type Query ¶ added in v1.0.1
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 v1.0.1
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 v1.0.1
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 v1.0.1
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 v1.0.1
type SelectParams struct {
*logproto.QueryRequest
}
SelectParams specifies parameters passed to data selections.
func (SelectParams) LogSelector ¶ added in v1.0.1
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 v1.0.1
type StepEvaluator interface {
Next() (bool, int64, promql.Vector)
}
StepEvaluator evaluate a single step of a query.
type StepEvaluatorFn ¶ added in v1.0.1
type StepEvaluatorFn func() (bool, int64, promql.Vector)
StepEvaluatorFn is a function to chain multiple `StepEvaluator`.
Source Files
¶
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. |