instance

package
v6.2.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2018 License: Apache-2.0 Imports: 45 Imported by: 1,666

Documentation

Overview

Package instance provides the functions required to manage the life-cycle of a Beat. It provides the standard mechanism for launching a Beat. It manages configuration, logging, and publisher initialization and registers a signal handler to gracefully stop the process.

Each Beat implementation must implement the `Beater` interface and a `Creator` to create and initialize the Beater instance. See the `Beater` interface and `Creator` documentation for more details.

To use this package, create a simple main that invokes the Run() function.

func main() {
	if err := beat.Run("mybeat", myVersion, beater.New); err != nil {
		os.Exit(1)
	}
}

In the example above, the beater package contains the implementation of the Beater interface and the New method returns a new instance of Beater. The Beater implementation is placed into its own package so that it can be reused or combined with other Beats.

Recommendations

  • Use the logp package for logging rather than writing to stdout or stderr.
  • Do not call os.Exit in any of your code. Return an error instead. Or if your code needs to exit without an error, return beat.GracefulExit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(name, idxPrefix, version string, bt beat.Creator) error

Run initializes and runs a Beater implementation. name is the name of the Beat (e.g. packetbeat or metricbeat). version is version number of the Beater implementation. bt is the `Creator` callback for creating a new beater instance. XXX Move this as a *Beat method?

Types

type Beat

type Beat struct {
	beat.Beat

	Config    beatConfig
	RawConfig *common.Config // Raw config that can be unpacked to get Beat specific config data.
	// contains filtered or unexported fields
}

Beat provides the runnable and configurable instance of a beat.

func NewBeat

func NewBeat(name, indexPrefix, v string) (*Beat, error)

NewBeat creates a new beat instance

func (*Beat) BeatConfig

func (b *Beat) BeatConfig() (*common.Config, error)

BeatConfig returns config section for this beat

func (*Beat) Init

func (b *Beat) Init() error

init does initialization of things common to all actions (read confs, flags)

func (*Beat) Keystore

func (b *Beat) Keystore() keystore.Keystore

Keystore return the configured keystore for this beat

func (*Beat) Setup

func (b *Beat) Setup(bt beat.Creator, template, dashboards, machineLearning bool) error

Setup registers ES index template and kibana dashboards

func (*Beat) TestConfig

func (b *Beat) TestConfig(bt beat.Creator) error

TestConfig check all settings are ok and the beat can be run

type TemplateConfig

type TemplateConfig struct {
	Enabled   bool              `config:"enabled"`
	Name      string            `config:"name"`
	Fields    string            `config:"fields"`
	Overwrite bool              `config:"overwrite"`
	Settings  map[string]string `config:"settings"`
}

Jump to

Keyboard shortcuts

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