filter

package
v2.5.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: MIT Imports: 12 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSeriesByTag = fmt.Errorf("not seriesByTag pattern")

ErrNotSeriesByTag is returned if the pattern is not seriesByTag

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled         bool
	Listen          string
	RetentionConfig string
}

Config is filter configuration settings

type ParsedMetric

type ParsedMetric struct {
	Metric    string
	Name      string
	Labels    map[string]string
	Value     float64
	Timestamp int64
}

ParsedMetric represents a result of ParseMetric.

func ParseMetric

func ParseMetric(input []byte) (*ParsedMetric, error)

ParseMetric parses metric from string supported format: "<metricString> <valueFloat64> <timestampInt64>"

type PatternIndex

type PatternIndex struct {
	Root *PatternNode
}

PatternIndex helps to index patterns and allows to match them by metric

func NewPatternIndex

func NewPatternIndex(patterns []string) *PatternIndex

NewPatternIndex creates new PatternIndex using patterns

func (*PatternIndex) MatchPatterns

func (source *PatternIndex) MatchPatterns(metric string) []string

MatchPatterns allows to match pattern by metric

type PatternNode

type PatternNode struct {
	Children   []*PatternNode
	Part       string
	Hash       uint32
	Prefix     string
	InnerParts []string
}

PatternNode contains pattern node

type PatternStorage

type PatternStorage struct {
	PatternIndex            atomic.Value
	SeriesByTagPatternIndex atomic.Value
	// contains filtered or unexported fields
}

PatternStorage contains pattern tree

func NewPatternStorage

func NewPatternStorage(database moira.Database, metrics *graphite.FilterMetrics, logger moira.Logger) (*PatternStorage, error)

NewPatternStorage creates new PatternStorage struct

func (*PatternStorage) ProcessIncomingMetric

func (storage *PatternStorage) ProcessIncomingMetric(lineBytes []byte) *moira.MatchedMetric

ProcessIncomingMetric validates, parses and matches incoming raw string

func (*PatternStorage) Refresh

func (storage *PatternStorage) Refresh() error

Refresh builds pattern's indexes from redis data

type SeriesByTagPatternIndex

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

SeriesByTagPatternIndex helps to index the seriesByTag patterns and allows to match them by metric

func NewSeriesByTagPatternIndex

func NewSeriesByTagPatternIndex(tagSpecsByPattern map[string][]TagSpec) *SeriesByTagPatternIndex

NewSeriesByTagPatternIndex creates new SeriesByTagPatternIndex using seriesByTag patterns and parsed specs comes from ParseSeriesByTag

func (*SeriesByTagPatternIndex) MatchPatterns

func (index *SeriesByTagPatternIndex) MatchPatterns(name string, labels map[string]string) []string

MatchPatterns allows to match patterns by metric name and its labels

type Storage

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

Storage struct to store retention matchers

func NewCacheStorage

func NewCacheStorage(logger moira.Logger, metrics *graphite.FilterMetrics, reader io.Reader) (*Storage, error)

NewCacheStorage create new Storage

func (*Storage) EnrichMatchedMetric

func (storage *Storage) EnrichMatchedMetric(batch map[string]*moira.MatchedMetric, m *moira.MatchedMetric)

EnrichMatchedMetric calculate retention and filter cached values

type TagSpec

type TagSpec struct {
	Name     string
	Operator TagSpecOperator
	Value    string
}

TagSpec is a filter expression inside seriesByTag pattern

func ParseSeriesByTag

func ParseSeriesByTag(input string) ([]TagSpec, error)

ParseSeriesByTag parses seriesByTag pattern and returns tags specs

type TagSpecOperator

type TagSpecOperator string

TagSpecOperator represents an operator and it is used to query metric by tag value

const (
	// EqualOperator is a strict equality operator and it is used to query metric by tag's value
	EqualOperator TagSpecOperator = "="
	// NotEqualOperator is a strict non-equality operator and it is used to query metric by tag's value
	NotEqualOperator TagSpecOperator = "!="
	// MatchOperator is a match operator which helps to match metric by regex
	MatchOperator TagSpecOperator = "=~"
	// NotMatchOperator is a non-match operator which helps not to match metric by regex
	NotMatchOperator TagSpecOperator = "!=~"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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