aggregator

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2017 License: BSD-2-Clause-Views Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Funcs = map[string]Func{
	"avg":   Avg,
	"delta": Delta,
	"last":  Last,
	"max":   Max,
	"min":   Min,
	"stdev": Stdev,
	"sum":   Sum,
}

Functions

func Avg

func Avg(in []float64) float64

func Delta added in v0.9.0

func Delta(in []float64) float64

func Last added in v0.9.0

func Last(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 Stdev added in v0.9.0

func Stdev(in []float64) float64

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