tagquery

package
v0.0.0-...-15fa731 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2019 License: AGPL-3.0, BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expression

type Expression struct {
	Tag
	Operator              ExpressionOperator
	RequiresNonEmptyValue bool
	UsesRegex             bool
	Regex                 *regexp.Regexp
}

func ParseExpression

func ParseExpression(expression string) (Expression, error)

ParseQueryExpression takes a tag query expression as a string and validates it

func (*Expression) IsEqualTo

func (e *Expression) IsEqualTo(other Expression) bool

func (*Expression) StringIntoBuilder

func (e *Expression) StringIntoBuilder(builder *strings.Builder)

type ExpressionOperator

type ExpressionOperator uint16
const (
	EQUAL      ExpressionOperator = iota // =
	NOT_EQUAL                            // !=
	MATCH                                // =~        regular expression
	MATCH_TAG                            // __tag=~   relies on special key __tag. non-standard, required for `/metrics/tags` requests with "filter"
	NOT_MATCH                            // !=~
	PREFIX                               // ^=        exact prefix, not regex. non-standard, required for auto complete of tag values
	PREFIX_TAG                           // __tag^=   exact prefix with tag. non-standard, required for auto complete of tag keys
)

func (ExpressionOperator) StringIntoBuilder

func (o ExpressionOperator) StringIntoBuilder(builder *strings.Builder)

type Expressions

type Expressions []Expression

func ParseExpressions

func ParseExpressions(expressions []string) (Expressions, error)

func (Expressions) Sort

func (e Expressions) Sort()

Sort sorts all the expressions first by key, then by value, then by operator

func (Expressions) Strings

func (e Expressions) Strings() []string

type MetaTagRecord

type MetaTagRecord struct {
	MetaTags Tags
	Queries  Expressions
}

func ParseMetaTagRecord

func ParseMetaTagRecord(metaTags []string, queries []string) (MetaTagRecord, error)

func (*MetaTagRecord) HasMetaTags

func (m *MetaTagRecord) HasMetaTags() bool

HasMetaTags returns true if the meta tag record has one or more meta tags, otherwise it returns false

func (*MetaTagRecord) MatchesQueries

func (m *MetaTagRecord) MatchesQueries(other MetaTagRecord) bool

MatchesQueries compares another tag record's queries to this one's queries. Returns true if they are equal, otherwise false. It is assumed that all the queries are already sorted

type Query

type Query struct {
	// clause that operates on LastUpdate field
	From int64

	// clauses that operate on values. from expressions like tag<operator>value
	Expressions map[ExpressionOperator]Expressions

	// clause that operate on tags (keys)
	// we only need to support 1 condition for now: a prefix or match
	TagClause ExpressionOperator // to know the clause type. either PREFIX_TAG or MATCH_TAG (or 0 if unset)
	TagMatch  Expression         // only used for /metrics/tags with regex in filter param
	TagPrefix string             // only used for auto complete of tags to match exact prefix

	StartWith ExpressionOperator // choses the first clause to generate the initial result set (one of EQUAL PREFIX MATCH MATCH_TAG PREFIX_TAG)
}

func NewQuery

func NewQuery(expressions Expressions, from int64) (Query, error)

func NewQueryFromStrings

func NewQueryFromStrings(expressionStrs []string, from int64) (Query, error)

type Tag

type Tag struct {
	Key   string
	Value string
}

func ParseTag

func ParseTag(tag string) (Tag, error)

func (*Tag) StringIntoBuilder

func (t *Tag) StringIntoBuilder(builder *strings.Builder)

type Tags

type Tags []Tag

func ParseTags

func ParseTags(tags []string) (Tags, error)

func ParseTagsFromMetricName

func ParseTagsFromMetricName(name string) (Tags, error)

func (Tags) Len

func (t Tags) Len() int

func (Tags) Less

func (t Tags) Less(i, j int) bool

func (Tags) Strings

func (t Tags) Strings() []string

func (Tags) Swap

func (t Tags) Swap(i, j int)

Jump to

Keyboard shortcuts

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