helper

package
v0.0.0-...-320d922 Latest Latest
Warning

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

Go to latest
Published: May 10, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registry = Register{}

TODO: Global variables should be prevent.

This should be moved into the metricbeat object but can't because the init()
functions in each metricset are called before the beater object exists.

Functions

This section is empty.

Types

type MetricSet

type MetricSet struct {
	Name        string
	MetricSeter MetricSeter
	// Inherits config from module
	Config ModuleConfig
	Module *Module
}

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(ms *MetricSet, host string) (common.MapStr, error)
}

Interface for each metric

type Module

type Module struct {

	// Module config
	Config ModuleConfig

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

Module specifics. This must be defined by each module

func NewModule

func NewModule(cfg *ucfg.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"`
	Module     string   `config:"module"`
	MetricSets []string `config:"metricsets"`
	Enabled    bool     `config:"enabled"`

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

Base configuration for each module/metricsets combination

type Moduler

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

Interface for each module

type Register

type Register struct {
	Modulers     map[string]func() Moduler
	MetricSeters map[string]map[string]func() MetricSeter
}

func (*Register) AddMetricSeter

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

func (*Register) AddModuler

func (r *Register) AddModuler(name string, m func() Moduler)

AddModule registers the given module with the registry

func (*Register) GetMetricSet

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

GetMetricSet returns a new metricset instance for the given metricset name combined with the module name

func (*Register) GetModule

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

GetModule returns a new module instance for the given moduler name

Jump to

Keyboard shortcuts

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