Documentation ¶
Overview ¶
lql package contains parser's functions and structures for working with Logrange Query Language (LQL) The LQL supports the following constructions so far:
SELECT [<format string>] [FROM ({<tags>}|<tags expression)] [RANGE <time range>] [WHERE <fields expression>] [POSITION (head|tail|<specific pos>)] [OFFSET <number>][LIMIT <number>] SHOW PARTITIONS [({<tags>}|<tags expression)][OFFSET <number>][LIMIT <number>] SHOW PIPES [OFFSET <number>][LIMIT <number>] DESCRIBE PARTITION {<tags>} DESCRIBE PIPE <pipe name> TRUNCATE [({<tags>}|<tags expression)][MINSIZE <size>][MAXSIZE <size>][BEFORE <timestamp>][MAXDBSIZE <size>] CREATE PIPE <pipe name> [FROM ({<tags>}|<tags expression)] [WHERE <fields expression>] DELETE PIPE <pipe name>
This file is copied from github.com/alecthomas/participle/lexer and modified to provide choosing longest match regexp functionality
Index ¶
- Constants
- Variables
- type Condition
- type Create
- type DateTime
- type Delete
- type Describe
- type Expression
- type Identifier
- type Lql
- type OrCondition
- type Partitions
- type Pipe
- type Pipes
- type Position
- type Range
- type Select
- type Show
- type Size
- type Source
- type TagsExpFunc
- type TagsVal
- type Truncate
- type WhereExpFunc
- type XCondition
Constants ¶
const ( CMP_CONTAINS = "CONTAINS" CMP_HAS_PREFIX = "PREFIX" CMP_HAS_SUFFIX = "SUFFIX" CMP_LIKE = "LIKE" )
const ( OPND_TIMESTAMP = "ts" OPND_MESSAGE = "msg" )
fixed operands names
Variables ¶
var PositiveTagsExpFunc = func(tag.Set) bool { return true }
Functions ¶
This section is empty.
Types ¶
type Condition ¶
type Condition struct { Ident *Identifier ` @@` Op string ` (@("<"|">"|">="|"<="|"!="|"="|"CONTAINS"|"PREFIX"|"SUFFIX"|"LIKE"))` Value string ` (@String|@Ident|@Number)` }
type Expression ¶
type Expression struct {
Or []*OrCondition `@@ { "OR" @@ }`
}
func ParseExpr ¶
func ParseExpr(where string) (*Expression, error)
func (*Expression) String ¶
func (ex *Expression) String() string
type Identifier ¶ added in v0.1.1
type Identifier struct { Operand string ` (@Ident|@Keyword)` Params []*Identifier ` ("("@@ {"," @@} ")")?` }
func (*Identifier) String ¶ added in v0.1.1
func (id *Identifier) String() string
type Lql ¶
type OrCondition ¶
type OrCondition struct {
And []*XCondition `@@ { "AND" @@ }`
}
type Partitions ¶
type Pipe ¶
type Pipe struct { Name string `"PIPE" @Ident` From *Source `("FROM" @@)?` Where *Expression `("WHERE" @@)?` }
type Range ¶ added in v0.1.0
type Show ¶
type Show struct { Partitions *Partitions `("PARTITIONS" (@@)?` Pipes *Pipes `|"PIPES" (@@)?)` }
type Source ¶
type Source struct { Tags *TagsVal ` @Tags` Expr *Expression ` | @@ ` }
func ParseSource ¶
type TagsExpFunc ¶
TagsExpFunc returns true if the provided tag are matched with the expression
func BuildTagsExpFunc ¶
func BuildTagsExpFunc(tagsCond string) (TagsExpFunc, error)
BuildTagsExpFuncByCond receives a condition line and parses it to the TagsExpFunc The tagCond could be provided in one of the following 2 forms:
- conditions like: name=app1 and ip like '123.*'
- tag-line like: {name=app1,ip=123.46.32.44}
func BuildTagsExpFuncBySource ¶
func BuildTagsExpFuncBySource(src *Source) (TagsExpFunc, error)
BuildTagsExpFuncBySource
type Truncate ¶
type Truncate struct { DryRun bool `(@"DRYRUN")?` Source *Source `(@@)?` MinSize *Size `("MINSIZE" @Number)?` MaxSize *Size `("MAXSIZE" @Number)?` Before *DateTime `("BEFORE" @String)?` MaxDbSize *Size `("MAXDBSIZE" @Number)?` }
func (*Truncate) GetMaxSize ¶
func (*Truncate) GetMinSize ¶
func (*Truncate) GetTagsCond ¶
type WhereExpFunc ¶
WhereExpFunc returns true if the provided LogEvent matches the where condition
func BuildWhereExpFunc ¶
func BuildWhereExpFunc(wCond string) (WhereExpFunc, error)
BuildWhereExpFunc buildw WHERE condition by the condition human readable form like `a=b AND c=d`
func BuildWhereExpFuncByExpression ¶
func BuildWhereExpFuncByExpression(exp *Expression) (WhereExpFunc, error)
BuildWhereExpFuncByExpression builds where function by the Expression provided
type XCondition ¶
type XCondition struct { Not bool ` [@"NOT"] ` Cond *Condition `( @@` Expr *Expression `| "(" @@ ")")` }