filters

package
v1.8.0-community Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LabelFilter

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

LabelFilter represents a condition based on a label name, value and matching operator. It applies to LogQL stream selectors and attribute filtering

func IPLabelFilter

func IPLabelFilter(labelKey, cidr string) LabelFilter

func MoreThanNumberLabelFilter

func MoreThanNumberLabelFilter(labelKey string, value string) LabelFilter

func MultiValuesRegexFilter

func MultiValuesRegexFilter(labelKey string, values []string, not bool) (LabelFilter, bool)

func NotIPLabelFilter

func NotIPLabelFilter(labelKey, cidr string) LabelFilter

func NotStringLabelFilter

func NotStringLabelFilter(labelKey string, value string) LabelFilter

func StringEqualLabelFilter

func StringEqualLabelFilter(labelKey string, value string) LabelFilter

func StringMatchLabelFilter

func StringMatchLabelFilter(labelKey string, value string) LabelFilter

func StringNotMatchLabelFilter

func StringNotMatchLabelFilter(labelKey string, value string) LabelFilter

func (*LabelFilter) WriteInto

func (f *LabelFilter) WriteInto(sb *strings.Builder)

type LineFilter

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

LineFilter represents a condition based on a JSON raw text match.

func ArrayLineFilter

func ArrayLineFilter(key string, values []string, not bool) LineFilter

func ExactMatchLineFilter

func ExactMatchLineFilter(key string, value string) LineFilter

func NewEmptyLineFilter

func NewEmptyLineFilter(key string, not, moreThan, allowEmpty bool) LineFilter

func NotContainsKeyLineFilter

func NotContainsKeyLineFilter(key string) LineFilter

func NumericLineFilter

func NumericLineFilter(key string, values []string, not, moreThan bool) (LineFilter, bool)

NumericLineFilter returns a LineFilter and true if it has an empty match

func RegexMatchLineFilter

func RegexMatchLineFilter(key string, strictKey bool, value string) LineFilter

func StringLineFilterCheckExact

func StringLineFilterCheckExact(key string, values []string, not bool) (LineFilter, bool)

StringLineFilterCheckExact returns a LineFilter and true if it has an empty match

func (*LineFilter) AsLabelFilters

func (f *LineFilter) AsLabelFilters() []LabelFilter

AsLabelFilters transforms a LineFilter (raw text match) into a group of labelFilters (attributes match)

func (LineFilter) MatchFalse

func (f LineFilter) MatchFalse() LineFilter

func (LineFilter) MatchTrue

func (f LineFilter) MatchTrue() LineFilter

func (*LineFilter) WriteInto

func (f *LineFilter) WriteInto(sb *strings.Builder)

WriteInto transforms a LineFilter to its corresponding part of a LogQL query under construction (contained in the provided strings.Builder)

type Match

type Match struct {
	Key             string
	Values          string
	Not             bool
	MoreThanOrEqual bool
}

func NewMatch

func NewMatch(key, values string) Match

func NewMoreThanOrEqualMatch added in v0.1.11

func NewMoreThanOrEqualMatch(key, values string) Match

func NewNotMatch

func NewNotMatch(key, values string) Match

func (*Match) ToLabelFilter

func (m *Match) ToLabelFilter() (LabelFilter, bool)

type MultiQueries

type MultiQueries []SingleQuery

MultiQueries is an union group of singleQueries (OR'ed)

func Parse

func Parse(raw string) (MultiQueries, error)

Example of raw filters (url-encoded): foo=a,b&bar=c|baz=d Produces: [ [ ["foo", "a,b"], ["bar", "c"]], [["baz", "d"]]] ^ ^ ^ | | '--- Per-label OR: "foo" must have value "a" OR "b" | '----- In-group AND: "foo" must be "a" or "b" AND "bar" must be "c" '------- All groups OR: "foo" must be "a" or "b" AND "bar" must be "c", OR "baz" must be "d"

func (MultiQueries) Distribute

func (m MultiQueries) Distribute(toDistribute []SingleQuery, ignorePred func(SingleQuery) bool) MultiQueries

Distribute allows to inject and "expand" queries with new filters. For example, say we have an initial query `q` with just "{{src-name=foo}}" and we want to enforce source OR dest namespace being "my-namespace". We'd write: `q.Distribute({{src-namespace="my-namespace"}, {dst-namespace="my-namespace"}})` Which results in: "{{src-namespace="my-namespace", src-name=foo}, {dst-namespace="my-namespace", src-name=foo}}"

type SingleQuery

type SingleQuery = []Match

singleQuery is an intersect group of matches (AND'ed)

Jump to

Keyboard shortcuts

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