beats: github.com/elastic/beats/libbeat/monitoring Index | Files | Directories

package monitoring

import "github.com/elastic/beats/libbeat/monitoring"

Index

Package Files

list.go metrics.go mode_string.go monitoring.go namespace.go opts.go registry.go snapshot.go visitor.go visitor_expvar.go visitor_kv.go

Variables

var Default = NewRegistry()

Default is the global default metrics registry provided by the monitoring package.

func Clear Uses

func Clear() error

func CollectStructSnapshot Uses

func CollectStructSnapshot(r *Registry, mode Mode, expvar bool) map[string]interface{}

CollectStructSnapshot collects a structured metrics snaphot of a metrics tree starting with the given registry. Empty namespaces will be omitted.

func Do Uses

func Do(mode Mode, f func(string, interface{}))

func DoExpvars Uses

func DoExpvars(f func(string, interface{}))

func DoNotReport Uses

func DoNotReport(o options) options

func IgnorePublishExpvar Uses

func IgnorePublishExpvar(o options) options

IgnorePublishExpvar disables publishing expvar variables in a sub-registry.

func PublishExpvar Uses

func PublishExpvar(o options) options

PublishExpvar enables publishing all registered variables via expvar interface. Note: expvar does not allow removal of any stats.

func Remove Uses

func Remove(name string)

func Report Uses

func Report(o options) options

func ReportBool Uses

func ReportBool(V Visitor, name string, value bool)

func ReportFloat Uses

func ReportFloat(V Visitor, name string, value float64)

func ReportInt Uses

func ReportInt(V Visitor, name string, value int64)

func ReportNamespace Uses

func ReportNamespace(V Visitor, name string, f func())

func ReportString Uses

func ReportString(V Visitor, name string, value string)

func ReportStringSlice Uses

func ReportStringSlice(V Visitor, name string, value []string)

func ReportVar Uses

func ReportVar(V Visitor, name string, m Mode, v Var)

func Visit Uses

func Visit(vs Visitor)

func VisitExpvars Uses

func VisitExpvars(vs Visitor)

VisitExpvars iterates all expvar metrics using the Visitor interface. The top-level metrics "memstats" and "cmdline", plus all monitoring.X metric types are ignored.

func VisitMode Uses

func VisitMode(mode Mode, vs Visitor)

type Bool Uses

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

Bool is a Bool variable satisfying the Var interface.

func NewBool Uses

func NewBool(r *Registry, name string, opts ...Option) *Bool

NewBool creates and registers a new bool variable.

Note: If the registry is configured to publish variables to expvar, the variable will be available via expvars package as well, but can not be removed anymore.

func (*Bool) Get Uses

func (v *Bool) Get() bool

func (*Bool) Set Uses

func (v *Bool) Set(value bool)

func (*Bool) Visit Uses

func (v *Bool) Visit(_ Mode, vs Visitor)

type FlatSnapshot Uses

type FlatSnapshot struct {
    Bools        map[string]bool
    Ints         map[string]int64
    Floats       map[string]float64
    Strings      map[string]string
    StringSlices map[string][]string
}

FlatSnapshot represents a flatten snapshot of all metrics. Names in the tree will be joined with `.` .

func CollectFlatSnapshot Uses

func CollectFlatSnapshot(r *Registry, mode Mode, expvar bool) FlatSnapshot

CollectFlatSnapshot collects a flattened snapshot of a metrics tree start with the given registry.

func MakeFlatSnapshot Uses

func MakeFlatSnapshot() FlatSnapshot

type Float Uses

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

Float is a 64 bit float variable satisfying the Var interface.

func NewFloat Uses

func NewFloat(r *Registry, name string, opts ...Option) *Float

NewFloat creates and registers a new float variable.

Note: If the registry is configured to publish variables to expvar, the variable will be available via expvars package as well, but can not be removed anymore.

func (*Float) Add Uses

func (v *Float) Add(delta float64)

func (*Float) Get Uses

func (v *Float) Get() float64

func (*Float) Set Uses

func (v *Float) Set(value float64)

func (*Float) Sub Uses

func (v *Float) Sub(delta float64)

func (*Float) Visit Uses

func (v *Float) Visit(_ Mode, vs Visitor)

type Func Uses

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

func NewFunc Uses

func NewFunc(r *Registry, name string, f func(Mode, Visitor), opts ...Option) *Func

func (*Func) Visit Uses

func (f *Func) Visit(m Mode, vs Visitor)

type FuncVar Uses

type FuncVar func(Mode, Visitor)

func (FuncVar) Visit Uses

func (f FuncVar) Visit(m Mode, vs Visitor)

type Int Uses

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

Int is a 64 bit integer variable satisfying the Var interface.

func NewInt Uses

func NewInt(r *Registry, name string, opts ...Option) *Int

NewInt creates and registers a new integer variable.

Note: If the registry is configured to publish variables to expvar, the variable will be available via expvars package as well, but can not be removed anymore.

func (*Int) Add Uses

func (v *Int) Add(delta int64)

func (*Int) Dec Uses

func (v *Int) Dec()

func (*Int) Get Uses

func (v *Int) Get() int64

func (*Int) Inc Uses

func (v *Int) Inc()

func (*Int) Set Uses

func (v *Int) Set(value int64)

func (*Int) Sub Uses

func (v *Int) Sub(delta int64)

func (*Int) Visit Uses

func (v *Int) Visit(_ Mode, vs Visitor)

type KeyValueVisitor Uses

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

func NewKeyValueVisitor Uses

func NewKeyValueVisitor(cb func(string, interface{})) *KeyValueVisitor

func (*KeyValueVisitor) OnBool Uses

func (vs *KeyValueVisitor) OnBool(b bool)

func (*KeyValueVisitor) OnFloat Uses

func (vs *KeyValueVisitor) OnFloat(f float64)

func (*KeyValueVisitor) OnInt Uses

func (vs *KeyValueVisitor) OnInt(i int64)

func (*KeyValueVisitor) OnKey Uses

func (vs *KeyValueVisitor) OnKey(name string)

func (*KeyValueVisitor) OnNil Uses

func (vs *KeyValueVisitor) OnNil()

func (*KeyValueVisitor) OnRegistryFinished Uses

func (vs *KeyValueVisitor) OnRegistryFinished()

func (*KeyValueVisitor) OnRegistryStart Uses

func (vs *KeyValueVisitor) OnRegistryStart()

func (*KeyValueVisitor) OnString Uses

func (vs *KeyValueVisitor) OnString(s string)

func (*KeyValueVisitor) OnStringSlice Uses

func (vs *KeyValueVisitor) OnStringSlice(f []string)

type Mode Uses

type Mode uint8
const (
    // Reported mode, is lowest report level with most basic metrics only
    Reported Mode = iota

    // Full reports all metrics
    Full
)

go:generate stringer -type=Mode

func (Mode) String Uses

func (i Mode) String() string

type Namespace Uses

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

Namespace contains the name of the namespace and it's registry

func GetNamespace Uses

func GetNamespace(name string) *Namespace

GetNamespace gets the namespace with the given name. If the namespace does not exist yet, a new one is created.

func (*Namespace) GetRegistry Uses

func (n *Namespace) GetRegistry() *Registry

GetRegistry gets the registry of the namespace

func (*Namespace) SetRegistry Uses

func (n *Namespace) SetRegistry(r *Registry)

SetRegistry sets the registry of the namespace

type Namespaces Uses

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

Namespaces is a list of Namespace structs

func NewNamespaces Uses

func NewNamespaces() *Namespaces

NewNamespaces creates a new namespaces list

func (*Namespaces) Get Uses

func (n *Namespaces) Get(key string) *Namespace

Get returns the namespace for the given key. If the key does not exist, new namespace is created.

type Option Uses

type Option func(options) options

Option type for passing additional options to NewRegistry.

type Registry Uses

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

Registry to store variables and sub-registries. When adding or retrieving variables, all names are split on the `.`-symbol and intermediate registries will be generated.

func GetRegistry Uses

func GetRegistry(name string) *Registry

func NewRegistry Uses

func NewRegistry(opts ...Option) *Registry

NewRegistry create a new empty unregistered registry

func (*Registry) Add Uses

func (r *Registry) Add(name string, v Var, m Mode)

Add adds a new variable to the registry. The method panics if the variables name is already in use.

func (*Registry) Clear Uses

func (r *Registry) Clear() error

Clear removes all entries from the current registry

func (*Registry) Do Uses

func (r *Registry) Do(mode Mode, f func(string, interface{}))

func (*Registry) Get Uses

func (r *Registry) Get(name string) Var

Get tries to find a registered variable by name.

func (*Registry) GetRegistry Uses

func (r *Registry) GetRegistry(name string) *Registry

GetRegistry tries to find a sub-registry by name.

func (*Registry) NewRegistry Uses

func (r *Registry) NewRegistry(name string, opts ...Option) *Registry

NewRegistry creates and register a new registry

func (*Registry) Remove Uses

func (r *Registry) Remove(name string)

Remove removes a variable or a sub-registry by name

func (*Registry) Visit Uses

func (r *Registry) Visit(mode Mode, vs Visitor)

Visit uses the Visitor interface to iterate the complete metrics hierarchies. In case of the visitor reporting an error, Visit will return immediately, reporting the very same error.

type RegistryVisitor Uses

type RegistryVisitor interface {
    OnRegistryStart()
    OnRegistryFinished()
    OnKey(s string)
}

type String Uses

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

String is a string variable satisfying the Var interface.

func NewString Uses

func NewString(r *Registry, name string, opts ...Option) *String

NewString creates and registers a new string variable.

Note: If the registry is configured to publish variables to expvar, the variable will be available via expvars package as well, but can not be removed anymore.

func (*String) Clear Uses

func (v *String) Clear()

func (*String) Fail Uses

func (v *String) Fail(err error)

func (*String) Get Uses

func (v *String) Get() string

func (*String) Set Uses

func (v *String) Set(s string)

func (*String) Visit Uses

func (v *String) Visit(_ Mode, vs Visitor)

type Uint Uses

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

Uint is a 64bit unsigned integer variable satisfying the Var interface.

func NewUint Uses

func NewUint(r *Registry, name string, opts ...Option) *Uint

NewUint creates and registers a new unsigned integer variable.

Note: If the registry is configured to publish variables to expvar, the variable will be available via expvars package as well, but can not be removed anymore.

func (*Uint) Add Uses

func (v *Uint) Add(delta uint64)

func (*Uint) Dec Uses

func (v *Uint) Dec()

func (*Uint) Get Uses

func (v *Uint) Get() uint64

func (*Uint) Inc Uses

func (v *Uint) Inc()

func (*Uint) Set Uses

func (v *Uint) Set(value uint64)

func (*Uint) Sub Uses

func (v *Uint) Sub(delta uint64)

func (*Uint) Visit Uses

func (v *Uint) Visit(_ Mode, vs Visitor)

type UniqueList Uses

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

UniqueList is used to collect a list of items (strings) and get the total count and all unique strings.

func NewUniqueList Uses

func NewUniqueList() *UniqueList

NewUniqueList create a new UniqueList

func (*UniqueList) Add Uses

func (l *UniqueList) Add(item string)

Add adds an item to the list and increases the count for it.

func (*UniqueList) Remove Uses

func (l *UniqueList) Remove(item string)

Remove removes and item for the list and decreases the count.

func (*UniqueList) Report Uses

func (l *UniqueList) Report(m Mode, V Visitor)

Report can be used as reporting function for monitoring. It reports a total count value and a names array with all the items.

type ValueVisitor Uses

type ValueVisitor interface {
    OnString(s string)
    OnBool(b bool)
    OnInt(i int64)
    OnFloat(f float64)
    OnStringSlice(f []string)
}

type Var Uses

type Var interface {
    Visit(Mode, Visitor)
}

Var interface required for every metric to implement.

func Get Uses

func Get(name string) Var

type Visitor Uses

type Visitor interface {
    ValueVisitor
    RegistryVisitor
}

Visitor interface supports traversing a monitoring registry

Directories

PathSynopsis
adapter
report
report/elasticsearch
report/log

Package monitoring imports 9 packages (graph) and is imported by 427 packages. Updated 2019-01-22. Refresh now. Tools for package owners.