monitors

package
v3.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package monitors is the core logic for monitors. Monitors are what collect metrics from the environment. They have a simple interface that all must implement: the Configure method, which takes one argument of the same type that you pass as the configTemplate to the Register function. Optionally, monitors may implement the niladic Shutdown method to do cleanup.

Monitors will never be reused after the Shutdown method is called.

The new monitor instance will be created for each service monitored. The Configure method will be called at most one time after the monitor is instantiated. Monitors should start any long running routines in the Configure method and start monitoring immediately.

Monitors are responsible for sending datapoints on the configured interval (the IntervalSeconds field of the config struct). There is no "read" callback method that will be called, so it is up to the monitors to maintain a timer however they wish to comply with the reporting interval.

If a monitor wants to create SignalFx golib datapoints/events and have them sent by the agent. The monitor type should define a "DPs" and/or "Events" field of the type "chan<- datapoints.Datapoint" and "chan<- events.Event". The monitor manager will automatically inject those fields before Configure is called. They could be swapped out at any time, so monitors should not cache those fields in other variables.

Monitors can also specify a field on their main monitor type (NOT their config) called "AgentMeta" of the type AgentMeta that provides monitors with access to agent global information, such as the hostname. Note that this information returned by the AgentMeta methods could change at any time, so monitors should call those methods each time it needs that information instead of caching it.

Index

Constants

This section is empty.

Variables

View Source
var ConfigTemplates = map[string]config.MonitorCustomConfig{}

ConfigTemplates are blank (zero-value) instances of the configuration struct for a particular monitor type.

View Source
var MonitorFactories = map[string]MonitorFactory{}

MonitorFactories holds all of the registered monitor factories

Functions

func DeregisterAll

func DeregisterAll()

DeregisterAll unregisters all monitor types. Primarily intended for testing purposes.

func Register

func Register(_type string, factory MonitorFactory, configTemplate config.MonitorCustomConfig)

Register a new monitor type with the agent. This is intended to be called from the init function of the module of a specific monitor implementation. configTemplate should be a zero-valued struct that is of the same type as the parameter to the Configure method for this monitor type.

Types

type ActiveMonitor

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

ActiveMonitor is a wrapper for an actual monitor instance that keeps some metadata about the monitor, such as the set of service endpoints attached to the monitor, as well as a copy of its configuration. It exposes a lot of methods to help manage the monitor as well.

func (*ActiveMonitor) Shutdown

func (am *ActiveMonitor) Shutdown()

Shutdown calls Shutdown on the monitor instance if it is provided.

type Initializable

type Initializable interface {
	Init() error
}

Initializable represents a monitor that has a distinct InitMonitor method. This should be called once after the monitor is created and before any of its other methods are called. It is useful for things that are not appropriate to do in the monitor factory function.

type InjectableMonitor

type InjectableMonitor interface {
	AddService(services.Endpoint)
	RemoveService(services.Endpoint)
}

InjectableMonitor should be implemented by a dynamic monitor that needs to know when services are added and removed.

type MonitorFactory

type MonitorFactory func() interface{}

MonitorFactory is a niladic function that creates an unconfigured instance of a monitor.

type MonitorManager

type MonitorManager struct {
	DPs            chan<- *datapoint.Datapoint
	Events         chan<- *event.Event
	DimensionProps chan<- *types.DimProperties
	// contains filtered or unexported fields
}

MonitorManager coordinates the startup and shutdown of monitors based on the configuration provided by the user. Monitors that have discovery rules can be injected with multiple services. If a monitor does not have a discovery rule (a "static" monitor), it will be started immediately (as soon as Configure is called).

func NewMonitorManager

func NewMonitorManager(agentMeta *meta.AgentMeta) *MonitorManager

NewMonitorManager creates a new instance of the MonitorManager

func (*MonitorManager) Configure

func (mm *MonitorManager) Configure(confs []config.MonitorConfig, collectdConf *config.CollectdConfig, intervalSeconds int)

Configure receives a list of monitor configurations. It will start up any static monitors and watch discovered services to see if any match dynamic monitors.

func (*MonitorManager) DiagnosticText

func (mm *MonitorManager) DiagnosticText() string

DiagnosticText returns a string to be served on the diagnostic socket

func (*MonitorManager) EndpointAdded

func (mm *MonitorManager) EndpointAdded(endpoint services.Endpoint)

EndpointAdded should be called when a new service is discovered

func (*MonitorManager) EndpointRemoved

func (mm *MonitorManager) EndpointRemoved(endpoint services.Endpoint)

EndpointRemoved should be called by observers when a service endpoint was removed.

func (*MonitorManager) InternalMetrics

func (mm *MonitorManager) InternalMetrics() []*datapoint.Datapoint

InternalMetrics returns a list of datapoints about the internal status of the monitors

func (*MonitorManager) Shutdown

func (mm *MonitorManager) Shutdown()

Shutdown will shutdown all managed monitors and deinitialize the manager.

type Shutdownable

type Shutdownable interface {
	Shutdown()
}

Shutdownable should be implemented by all monitors that need to clean up resources before being destroyed.

Directories

Path Synopsis
Package cadvisor contains a monitor that pulls cadvisor stats either directly from cadvisor or from the kubelet /stats endpoint that exposes cadvisor.
Package cadvisor contains a monitor that pulls cadvisor stats either directly from cadvisor or from the kubelet /stats endpoint that exposes cadvisor.
activemq
Package activemq has an ActiveMQ Collectd monitor that uses GenericJMX
Package activemq has an ActiveMQ Collectd monitor that uses GenericJMX
cpu
custom
Package custom contains a custom collectd plugin monitor, for which you can specify your own config template and parameters.
Package custom contains a custom collectd plugin monitor, for which you can specify your own config template and parameters.
df
genericjmx
Package genericjmx coordinates the various monitors that rely on the GenericJMX Collectd plugin to pull JMX metrics.
Package genericjmx coordinates the various monitors that rely on the GenericJMX Collectd plugin to pull JMX metrics.
netinterface
Package netinterface wraps the "interface" collectd plugin for gather network interface metrics.
Package netinterface wraps the "interface" collectd plugin for gather network interface metrics.
Package docker contains a monitor for getting metrics about containers running in a docker engine.
Package docker contains a monitor for getting metrics about containers running in a docker engine.
cluster
Package cluster contains a Kubernetes cluster monitor.
Package cluster contains a Kubernetes cluster monitor.
Package types exists to avoid circular references between things that need to reference common types
Package types exists to avoid circular references between things that need to reference common types

Jump to

Keyboard shortcuts

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