beater

package
v6.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2018 License: Apache-2.0 Imports: 15 Imported by: 497

Documentation

Overview

Package beater provides the implementation of the libbeat Beater interface for Metricbeat and functions for running Metricbeat Modules on their own.

Metricbeat collects metrics from operating systems and services. The code for gathering metrics from a particular service is organized into a logical grouping called a Module. Each Module has one or more MetricSet implementations which do the work of collecting a particular set of metrics from the service.

The public interfaces used in implementing Modules and MetricSets are defined in the github.com/elastic/beats/metricbeat/mb package.

Event Format

Each event generated by Metricbeat has the same general structure. The example event below was generated by a MetricSet named "cpu" in the "system" Module.

{
	"@timestamp": "2016-05-23T08:05:34.853Z",
	"beat": {
		"hostname": "host.example.com",
		"name": "host.example.com"
	},
	"metricset": {
		"host": "localhost",
		"module": "system",
		"name": "cpu",
		"rtt": 115
	},
	"system": {
		"cpu": {
			"idle": {
				"pct": 0.852,
				"ticks": 44421033
			},
			"iowait": {
				"pct": 0,
				"ticks": 159735
			},
			"irq": {
				"pct": 0,
				"ticks": 0
			},
			"nice": {
				"pct": 0,
				"ticks": 0
			},
			"softirq": {
				"pct": 0,
				"ticks": 14070
			},
			"steal": {
				"pct": 0,
				"ticks": 0
			},
			"system": {
				"pct": 0.0408,
				"ticks": 305704
			},
			"user": {
				"pct": 0.1071,
				"ticks": 841974
			}
		}
	},
	"type": "metricsets"
}

All events are stored in one index called metricbeat by default. Each MetricSet's data format is potentially unique so the MetricSet data is added to event as a dictionary under a key that is unique to the MetricSet. The key is constructed from the Module name and MetricSet name to ensure uniqueness. All documents are stored under the same type called "metricsets".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Creator

func Creator(options ...Option) beat.Creator

Creator returns a beat.Creator for instantiating a new instance of the Metricbeat framework with the given options.

func DefaultCreator

func DefaultCreator() beat.Creator

DefaultCreator returns a beat.Creator for instantiating a new instance of Metricbeat framework with the traditional Metricbeat module option of module.WithMetricSetInfo.

This is equivalent to calling

beater.Creator(
    beater.WithModuleOptions(
        module.WithMetricSetInfo(),
    ),
)

Types

type AutodiscoverAdapter

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

AutodiscoverAdapter for Metricbeat modules

func NewAutodiscoverAdapter

func NewAutodiscoverAdapter(factory cfgfile.RunnerFactory) *AutodiscoverAdapter

NewAutodiscoverAdapter builds and returns an autodiscover adapter for Metricbeat modules

func (*AutodiscoverAdapter) CheckConfig

func (m *AutodiscoverAdapter) CheckConfig(c *common.Config) error

CheckConfig tests given config to check if it will work or not, returns errors in case it won't work

func (*AutodiscoverAdapter) Create

Create a module or prospector from the given config

func (*AutodiscoverAdapter) CreateConfig

func (m *AutodiscoverAdapter) CreateConfig(e bus.Event) ([]*common.Config, error)

CreateConfig generates a valid list of configs from the given event, the received event will have all keys defined by `StartFilter`

func (*AutodiscoverAdapter) EventFilter

func (m *AutodiscoverAdapter) EventFilter() []string

EventFilter returns the bus filter to retrieve runner start/stop triggering events

type Config

type Config struct {
	// Modules is a list of module specific configuration data.
	Modules       []*common.Config     `config:"modules"`
	ConfigModules *common.Config       `config:"config.modules"`
	MaxStartDelay time.Duration        `config:"max_start_delay"` // Upper bound on the random startup delay for metricsets (use 0 to disable startup delay).
	Autodiscover  *autodiscover.Config `config:"autodiscover"`
}

Config is the root of the Metricbeat configuration hierarchy.

type Metricbeat

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

Metricbeat implements the Beater interface for metricbeat.

func (*Metricbeat) Modules

func (bt *Metricbeat) Modules() ([]*module.Wrapper, error)

Modules return a list of all configured modules, including anyone present under dynamic config settings.

func (*Metricbeat) Run

func (bt *Metricbeat) Run(b *beat.Beat) error

Run starts the workers for Metricbeat and blocks until Stop is called and the workers complete. Each host associated with a MetricSet is given its own goroutine for fetching data. The ensures that each host is isolated so that a single unresponsive host cannot inadvertently block other hosts within the same Module and MetricSet from collection.

func (*Metricbeat) Stop

func (bt *Metricbeat) Stop()

Stop signals to Metricbeat that it should stop. It closes the "done" channel and closes the publisher client associated with each Module.

Stop should only be called a single time. Calling it more than once may result in undefined behavior.

type Option

type Option func(mb *Metricbeat)

Option specifies some optional arguments used for configuring the behavior of the Metricbeat framework.

func WithModuleOptions

func WithModuleOptions(options ...module.Option) Option

WithModuleOptions sets the given module options on the Metricbeat framework and these options will be used anytime a new module is instantiated.

Jump to

Keyboard shortcuts

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