monitoring

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 12 Imported by: 162

Documentation

Index

Constants

View Source
const TSLayout = "2006-01-02T15:04:05.000Z"

TsLayout is the layout to be used in the timestamp marshaling/unmarshaling.

Variables

View Source
var Default = NewRegistry()

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

Functions

func Clear

func Clear() error

func CollectStructSnapshot

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

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

func DoExpvars

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

func DoNotReport

func DoNotReport(o options) options

func GetClusterUUID

func GetClusterUUID(monitoringCfg *config.C) (string, error)

GetClusterUUID returns the value of the monitoring.cluster_uuid setting, if it is set.

func IgnorePublishExpvar

func IgnorePublishExpvar(o options) options

IgnorePublishExpvar disables publishing expvar variables in a sub-registry.

func IsBufferEnabled

func IsBufferEnabled(monitoringCfg *config.C) bool

IsBufferEnabled will check if the monitoring buffer is explicitly enabled.

func IsEnabled

func IsEnabled(monitoringCfg *config.C) bool

IsEnabled returns whether the monitoring reporter is enabled or not.

func OverrideWithCloudSettings

func OverrideWithCloudSettings(monitoringCfg *config.C) error

OverrideWithCloudSettings overrides monitoring.elasticsearch.* with monitoring.cloud.* if the latter are set.

func PublishExpvar

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

func Remove(name string)

func Report

func Report(o options) options

func ReportBool

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

ReportBool reports a bool for the visitor

func ReportFloat

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

ReportFloat reports a float type for the visitor

func ReportInt

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

ReportInt reports an int type for the visitor

func ReportNamespace

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

ReportNamespace reports a value for a given namespace

func ReportString

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

ReportString reports a string value for the visitor

func ReportStringSlice

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

ReportStringSlice reports a string array for the visitor

func ReportVar

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

ReportVar reports an interface var typew for the visitor

func Visit

func Visit(vs Visitor)

func VisitExpvars

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

func VisitMode(mode Mode, vs Visitor)

Types

type BeatConfig

type BeatConfig struct {
	Monitoring *config.C `config:"monitoring"`
}

BeatConfig represents the part of the $BEAT.yml to do with monitoring settings

type Bool

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

Bool is a Bool variable satisfying the Var interface.

func NewBool

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

func (v *Bool) Get() bool

func (*Bool) Set

func (v *Bool) Set(value bool)

func (*Bool) Visit

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

type FlatSnapshot

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

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

func MakeFlatSnapshot() FlatSnapshot

type Float

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

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

func NewFloat

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

func (v *Float) Add(delta float64)

func (*Float) Get

func (v *Float) Get() float64

func (*Float) Set

func (v *Float) Set(value float64)

func (*Float) Sub

func (v *Float) Sub(delta float64)

func (*Float) Visit

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

type Func

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

func NewFunc

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

func (*Func) Visit

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

type FuncVar

type FuncVar func(Mode, Visitor)

func (FuncVar) Visit

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

type Int

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

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

func NewInt

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

func (v *Int) Add(delta int64)

func (*Int) Dec

func (v *Int) Dec()

func (*Int) Get

func (v *Int) Get() int64

func (*Int) Inc

func (v *Int) Inc()

func (*Int) Set

func (v *Int) Set(value int64)

func (*Int) Sub

func (v *Int) Sub(delta int64)

func (*Int) Visit

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

type KeyValueVisitor

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

func NewKeyValueVisitor

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

func (*KeyValueVisitor) OnBool

func (vs *KeyValueVisitor) OnBool(b bool)

func (*KeyValueVisitor) OnFloat

func (vs *KeyValueVisitor) OnFloat(f float64)

func (*KeyValueVisitor) OnInt

func (vs *KeyValueVisitor) OnInt(i int64)

func (*KeyValueVisitor) OnKey

func (vs *KeyValueVisitor) OnKey(name string)

func (*KeyValueVisitor) OnNil

func (vs *KeyValueVisitor) OnNil()

func (*KeyValueVisitor) OnRegistryFinished

func (vs *KeyValueVisitor) OnRegistryFinished()

func (*KeyValueVisitor) OnRegistryStart

func (vs *KeyValueVisitor) OnRegistryStart()

func (*KeyValueVisitor) OnString

func (vs *KeyValueVisitor) OnString(s string)

func (*KeyValueVisitor) OnStringSlice

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

type Mode

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

	// Full reports all metrics
	Full
)

func (Mode) String

func (i Mode) String() string

type Namespace

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

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

func GetNamespace

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

func (n *Namespace) GetRegistry() *Registry

GetRegistry gets the registry of the namespace

func (*Namespace) SetRegistry

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

SetRegistry sets the registry of the namespace

type Namespaces

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

Namespaces is a list of Namespace structs

func NewNamespaces

func NewNamespaces() *Namespaces

NewNamespaces creates a new namespaces list

func (*Namespaces) Get

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

type Option func(options) options

Option type for passing additional options to NewRegistry.

type Registry

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

func GetRegistry(name string) *Registry

func NewRegistry

func NewRegistry(opts ...Option) *Registry

NewRegistry create a new empty unregistered registry

func (*Registry) Add

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

func (r *Registry) Clear() error

Clear removes all entries from the current registry

func (*Registry) Do

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

func (*Registry) Get

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

Get tries to find a registered variable by name.

func (*Registry) GetRegistry

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

GetRegistry tries to find a sub-registry by name.

func (*Registry) NewRegistry

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

NewRegistry creates and register a new registry

func (*Registry) Remove

func (r *Registry) Remove(name string)

Remove removes a variable or a sub-registry by name

func (*Registry) Visit

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

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

RegistryVisitor is the interface type for interacting with a monitoring registry

type String

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

String is a string variable satisfying the Var interface.

func NewString

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

func (v *String) Clear()

func (*String) Fail

func (v *String) Fail(err error)

func (*String) Get

func (v *String) Get() string

func (*String) Set

func (v *String) Set(s string)

func (*String) Visit

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

type Timestamp

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

Timestamp is a timestamp variable satisfying the Var interface.

func NewTimestamp

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

NewTimestamp creates and registers a new timestamp variable.

func (*Timestamp) Get

func (v *Timestamp) Get() time.Time

func (*Timestamp) Set

func (v *Timestamp) Set(t time.Time)

func (*Timestamp) Visit

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

type Uint

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

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

func NewUint

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

func (v *Uint) Add(delta uint64)

func (*Uint) Dec

func (v *Uint) Dec()

func (*Uint) Get

func (v *Uint) Get() uint64

func (*Uint) Inc

func (v *Uint) Inc()

func (*Uint) Set

func (v *Uint) Set(value uint64)

func (*Uint) Sub

func (v *Uint) Sub(delta uint64)

func (*Uint) Visit

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

type UniqueList

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

func NewUniqueList() *UniqueList

NewUniqueList create a new UniqueList

func (*UniqueList) Add

func (l *UniqueList) Add(item string)

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

func (*UniqueList) Remove

func (l *UniqueList) Remove(item string)

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

func (*UniqueList) Report

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

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

ValueVisitor is an interface for the monitoring visitor type

type Var

type Var interface {
	Visit(Mode, Visitor)
}

Var interface required for every metric to implement.

func Get

func Get(name string) Var

type Visitor

type Visitor interface {
	ValueVisitor
	RegistryVisitor
}

Visitor interface supports traversing a monitoring registry

Directories

Path Synopsis
report

Jump to

Keyboard shortcuts

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