helper

package
v5.0.0-alpha2+incompat... Latest Latest
Warning

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

Go to latest
Published: May 2, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registry = Register{}

Registry is the singleton Register instance where all modules and metricsets should register their factories.

Functions

This section is empty.

Types

type MetricSet

type MetricSet struct {
	Name        string
	MetricSeter MetricSeter
	// Inherits config from module
	Config ModuleConfig
	Module *Module
	// contains filtered or unexported fields
}

Metric specific data This must be defined by each metric

func NewMetricSet

func NewMetricSet(name string, new func() MetricSeter, module *Module) (*MetricSet, error)

Creates a new MetricSet

func (*MetricSet) Fetch

func (m *MetricSet) Fetch() error

RunMetric runs the given metricSet and returns the event

func (*MetricSet) Setup

func (m *MetricSet) Setup() error

type MetricSeter

type MetricSeter interface {
	// Setup of MetricSeter
	// MetricSet which contains the MetricSeter is passed. This gives access to config
	// and the module.
	Setup(ms *MetricSet) error

	// Method to periodically fetch a new event from a host
	// Fetch is called for each host. In case where host does not exist, it can be transferred
	// differently in the setup to have a different meaning. An example here is for filesystem
	// of topbeat, where each host could be a filesystem.
	// Fetch is called on the predefined interval and does not take delays into account.
	Fetch(ms *MetricSet, host string) (common.MapStr, error)
}

Interface for each metric

type Module

type Module struct {

	// Module config
	Config ModuleConfig

	Timeout time.Duration

	Publish chan common.MapStr
	// contains filtered or unexported fields
}

Module specifics. This must be defined by each module

func NewModule

func NewModule(cfg *common.Config, moduler func() Moduler) (*Module, error)

NewModule creates a new module

func (*Module) FetchMetricSets

func (m *Module) FetchMetricSets(metricSet *MetricSet)

func (*Module) ProcessConfig

func (m *Module) ProcessConfig(config interface{}) error

ProcessConfig allows to process additional configuration params which are not part of the module default configuratoin. This allows each metricset to have its specific config params

func (*Module) Run

func (m *Module) Run(period time.Duration, b *beat.Beat)

func (*Module) Start

func (m *Module) Start(b *beat.Beat) error

Starts the given module

func (*Module) Stop

func (m *Module) Stop()

Stop stops module and all its metricSets

type ModuleConfig

type ModuleConfig struct {
	Hosts      []string              `config:"hosts"`
	Period     string                `config:"period"`
	Timeout    string                `config:"timeout"`
	Module     string                `config:"module"`
	MetricSets []string              `config:"metricsets"`
	Enabled    bool                  `config:"enabled"`
	Filters    []filter.FilterConfig `config:"filters"`

	common.EventMetadata `config:",inline"` // Fields and tags to add to events.
}

Base configuration for each module/metricsets combination

type Moduler

type Moduler interface {
	// Raw *common.Config config is passed. This allows each module to extract its own local config variables
	Setup(m *Module) error
}

Interface for each module

type Register

type Register struct {
	Modulers     map[string]func() Moduler                // A map of module name to Moduler factory function.
	MetricSeters map[string]map[string]func() MetricSeter // A map of module name to nested map of metricset name to MetricSeter factory function.
}

Register contains the factory functions for creating new Modulers and new MetricSeters.

func (*Register) AddMetricSeter

func (r *Register) AddMetricSeter(module string, name string, factory func() MetricSeter) error

AddMetricSeter registers a new MetricSeter factory. An error is returned if any parameter is empty or nil or if a factory has already been registered under the name.

func (*Register) AddModuler

func (r *Register) AddModuler(name string, factory func() Moduler) error

AddModuler registers a new Moduler factory. An error is returned if the name is empty, factory is nil, or if a factory has already been registered under the name.

func (*Register) GetMetricSet

func (r *Register) GetMetricSet(module *Module, name string) (*MetricSet, error)

GetMetricSet returns a new MetricSet instance given the module and metricset name. An error is returned if the module or metricset do not exist.

func (*Register) GetModule

func (r *Register) GetModule(cfg *common.Config) (*Module, error)

GetModule returns a new Module instance for the given moduler name. An error is returned if the module does not exist.

func (Register) String

func (r Register) String() string

String return a string representation of the registered modules and metricsets.

Jump to

Keyboard shortcuts

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