metrics

package
v0.0.0-...-ce0f0b0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const SeparatorByte byte = 255

fo handling collsion like {"foo", "bar"} and {"foob", "ar"}

Variables

This section is empty.

Functions

func Alerts

func Alerts() *chan Monitor

func Avg

func Avg(ps PointSeries) float64

func Gather

func Gather()

func LabelsEqual

func LabelsEqual(a, b []string) bool

func NewAlertManager

func NewAlertManager() *alertManager

func NewMemSeries

func NewMemSeries(id uint64, lset Labels, chunkRange int64) *memSeries

func Register

func Register(cs ...Collector)

func RegisterMonitor

func RegisterMonitor(ms ...Monitor)

func SetCollectInterval

func SetCollectInterval(i int)

func StartAlertManager

func StartAlertManager()

Types

type Collector

type Collector interface {
	Describe(chan<- *Desc)
	Collect(chan<- Metric)
}

type Counter

type Counter interface {
	Collector
	Inc()
	Add(float64)
}

type CounterVec

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

func NewCounterVec

func NewCounterVec(name string, help string, labelNames []string) *CounterVec

func (*CounterVec) WithLabelValues

func (v *CounterVec) WithLabelValues(lvs ...string) Counter

type Desc

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

details of the metric

func NewDesc

func NewDesc(name string, help string, labelNames []string) *Desc

func (*Desc) String

func (d *Desc) String() string

type Iterator

type Iterator interface {
	// Next advances the iterator by one.
	Next() bool
	// Seek advances the iterator forward to the first sample with the timestamp equal or greater than t.
	// If current sample found by previous `Next` or `Seek` operation already has this property, Seek has no effect.
	// Seek returns true, if such sample exists, false otherwise.
	// Iterator is exhausted when the Seek returns false.
	Seek(t int64) bool
	// At returns the current timestamp/value pair.
	// Before the iterator has advanced At behaviour is unspecified.
	At() (int64, float64)
	// Err returns the current error. It should be used only after iterator is
	// exhausted, that is `Next` or `Seek` returns false.
	Err() error
}

type Label

type Label struct {
	Name, Value string
}

type LabelPair

type LabelPair struct {
	Name  *string
	Value *string
}

type Labels

type Labels []Label

func (Labels) Hash

func (ls Labels) Hash() uint64

func (Labels) Len

func (ls Labels) Len() int

func (Labels) Less

func (ls Labels) Less(i, j int) bool

func (Labels) String

func (ls Labels) String() string

func (Labels) Swap

func (ls Labels) Swap(i, j int)

type Matrix

type Matrix []PointSeries

func QueryLast

func QueryLast(name string, selector Labels, last int64, evalInterval int64) Matrix

func SumBy

func SumBy(m Matrix, by []string) Matrix

type Metric

type Metric interface {
	Desc() *Desc
	Value() float64
	Labels() Labels
}

type Monitor

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

func NewMonitor

func NewMonitor(name string, duration int64, threshold float64, eval func() float64) *Monitor

func (*Monitor) Status

func (m *Monitor) Status() string

func (*Monitor) String

func (m *Monitor) String() string

type PointSeries

type PointSeries struct {
	Metric Labels
	Points []float64
	// contains filtered or unexported fields
}

Series is a stream of data points belonging to a metric.

func NewPointSeries

func NewPointSeries(labels Labels, evalInterval int64) *PointSeries

func Rate

func Rate(ps PointSeries) PointSeries

func Sum

func Sum(m Matrix) PointSeries

func (*PointSeries) EvalInterval

func (ps *PointSeries) EvalInterval() int64

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) QueryLast

func (r *Registry) QueryLast(name string, selector Labels, last int64, evalInterval int64) Matrix

func (*Registry) Register

func (r *Registry) Register(c Collector) error

func (*Registry) Select

func (r *Registry) Select(name string, selector Labels) []*memSeries

type Sample

type Sample struct {
	T int64
	V float64
}

Point represents a single data point for a given timestamp.

type Series

type Series interface {
	// Labels returns the complete set of labels identifying the series.
	Labels() Labels
	// Iterator returns a new iterator of the data of the series.
	Iterator() Iterator
	// Appender returns an appender to append samples to the series.
	//Appender() (Appender, error)
	// NumSamples returns the number of samples in the series.
	NumSamples() int
}

Jump to

Keyboard shortcuts

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