filter

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package filter implements fast wildcard like filtering based on suffix tree.

Filter Suffix Tree

Build suffix tree by rules, for example:

rules : a.b.c.d, a.b.c.e a.*.c.e
a
| \
b  *
|  |
c  c
|\  \
d e  e

Rules are split into some words by '.', which wil be a node in the suffix tree. Parent node are suffix to the word of child node. When a metric comes, the filter search the suffix to find all matched rules at same time.

For example:

a.b.c.e comes, the filter find 'a', then goto children node 'b' and '*', until metric
ends or no node matched next word of metric.In the end return two rules 'a.b.c.e' and
'a.*.c.e'.

Use suffix tree can find all matched rules at same time, it's far fast than match the rule one by one.

Filter add and del rules by chan.

A rule in the filter can be hit by metric for the intervalHitLimit times in an interval at most. This can help banshee limiting the metric pass.

Package filter implements fast wildcard like filtering based on trie.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Filter is to filter metrics by rules.

func New

func New(cfg *config.Config) *Filter

New creates a new Filter.

func (*Filter) Init

func (f *Filter) Init(db *storage.DB)

Init filter.

func (*Filter) MatchedRules

func (f *Filter) MatchedRules(m *models.Metric, shouldLimitHit bool) (rules []*models.Rule)

MatchedRules returns the matched rules by metric name.

Jump to

Keyboard shortcuts

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