aggregator

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2017 License: BSD-2-Clause-Views Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Funcs = map[string]Func{
	"sum": Sum,
	"avg": Avg,
	"max": Max,
	"min": Min,
}

Functions

func Avg

func Avg(in []float64) float64

func Max

func Max(in []float64) float64

func Min

func Min(in []float64) float64

func SetLogger

func SetLogger(l *logging.Logger)

func Sum

func Sum(in []float64) float64

Types

type Aggregator

type Aggregator struct {
	Fun string `json:"fun"`

	In chan [][]byte `json:"-"` // incoming metrics, already split in 3 fields

	Regex string `json:"regex,omitempty"`

	OutFmt string

	Interval uint // expected interval between values in seconds, we will quantize to make sure alginment to interval-spaced timestamps
	Wait     uint // seconds to wait after quantized time value before flushing final outcome and ignoring future values that are sent too late.
	// contains filtered or unexported fields
}

func New

func New(fun, regex, outFmt string, interval, wait uint, out chan []byte) (*Aggregator, error)

New creates an aggregator

func (*Aggregator) AddOrCreate

func (a *Aggregator) AddOrCreate(key string, ts uint, value float64)

func (*Aggregator) Flush

func (a *Aggregator) Flush(ts uint)

Flush finalizes and removes aggregations that are due

func (*Aggregator) PreMatch

func (agg *Aggregator) PreMatch(buf []byte) bool

PreMatch checks if the specified metric might match the regex by comparing it to the prefix derived from the regex if this returns false, the metric will definitely not match the regex and be ignored.

func (*Aggregator) Shutdown

func (agg *Aggregator) Shutdown()

func (*Aggregator) Snapshot

func (agg *Aggregator) Snapshot() *Aggregator

to view the state of the aggregator at any point in time

type Func

type Func func(in []float64) float64

Jump to

Keyboard shortcuts

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