filter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2016 License: MIT Imports: 9 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 suffix tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

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

Filter is to filter metrics by rules.

func New

func New() *Filter

New creates a filter.

func (*Filter) DisableHitLimit added in v0.1.2

func (f *Filter) DisableHitLimit()

DisableHitLimit disable hit limit.

func (*Filter) EnableHitLimit added in v0.1.2

func (f *Filter) EnableHitLimit()

EnableHitLimit enable hit limit.

func (*Filter) Init

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

Init from db.

func (*Filter) MatchedRules

func (f *Filter) MatchedRules(m *models.Metric) []*models.Rule

MatchedRules checks if a metric hit the hitCache, if hit return all hit rules

func (*Filter) SetHitLimit

func (f *Filter) SetHitLimit(cfg *config.Config)

SetHitLimit start to clear hitCounters by Interval

Jump to

Keyboard shortcuts

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