module

package
v6.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func PublishChannels

func PublishChannels(client beat.Client, cs ...<-chan beat.Event)

PublishChannels publishes the events read from each channel to the given publisher client. If the publisher client blocks for any reason then events will not be read from the given channels.

This method blocks until all of the channels have been closed and are fully read. To stop the method immediately, close the channels and close the publisher client to ensure that publishing does not block. This may result is some events being discarded.

Types

type Connector

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

Connector configures ann establishes a beat.Client for publishing events to the publisher pipeline.

func NewConnector

func NewConnector(pipeline beat.Pipeline, c *common.Config, dynFields *common.MapStrPointer) (*Connector, error)

func (*Connector) Connect

func (c *Connector) Connect() (beat.Client, error)

type EventBuilder

type EventBuilder struct {
	ModuleName    string
	MetricSetName string
	Host          string
	StartTime     time.Time
	FetchDuration time.Duration
	Event         common.MapStr
	// contains filtered or unexported fields
}

EventBuilder is used for building MetricSet events. MetricSets generate a data in the form of a common.MapStr. This builder transforms that data into a complete event and applies any Module-level filtering.

func (EventBuilder) Build

func (b EventBuilder) Build() (beat.Event, error)

Build builds an event from MetricSet data and applies the Module-level filters.

type Factory

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

Factory creates new Runner instances from configuration objects. It is used to register and reload modules.

func NewFactory

func NewFactory(maxStartDelay time.Duration, p beat.Pipeline) *Factory

NewFactory creates new Reloader instance for the given config

func (*Factory) Create

func (r *Factory) Create(c *common.Config, meta *common.MapStrPointer) (cfgfile.Runner, error)

type Runner

type Runner interface {
	// Start starts the Module. If Start is called more than once, only the
	// first will start the Module.
	Start()

	// Stop stops the Module and waits for module's MetricSets to exit. The
	// publisher.Client will be closed by Stop. If Stop is called more than
	// once, only the first stop the Module and wait for it to exit.
	Stop()
}

Runner is a facade for a Wrapper that provides a simple interface for starting and stopping a Module.

Example

ExampleRunner demonstrates how to use Runner to start and stop a module.

Output:

func NewRunner

func NewRunner(client beat.Client, mod *Wrapper) Runner

NewRunner returns a Runner facade. The events generated by the Module will be published to a new publisher.Client generated from the pubClientFactory.

type Wrapper

type Wrapper struct {
	mb.Module
	// contains filtered or unexported fields
}

Wrapper contains the Module and the private data associated with running the Module and its MetricSets.

Use NewWrapper or NewWrappers to construct new Wrappers.

Example

ExampleWrapper demonstrates how to create a single Wrapper from configuration, start the module, and consume events generated by the module.

Output:

{
  "@metadata": {
    "beat": "noindex",
    "type": "doc",
    "version": "1.2.3"
  },
  "@timestamp": "2016-05-10T23:27:58.485Z",
  "fake": {
    "eventfetcher": {
      "metric": 1
    }
  },
  "metricset": {
    "module": "fake",
    "name": "eventfetcher",
    "rtt": 111
  }
}

func NewWrapper

func NewWrapper(maxStartDelay time.Duration, config *common.Config, r *mb.Register) (*Wrapper, error)

NewWrapper create a new Module and its associated MetricSets based on the given configuration.

func (*Wrapper) MetricSets

func (mw *Wrapper) MetricSets() []*metricSetWrapper

MetricSets return the list of metricsets of the module

func (*Wrapper) Start

func (mw *Wrapper) Start(done <-chan struct{}) <-chan beat.Event

Start starts the Module's MetricSet workers which are responsible for fetching metrics. The workers will continue to periodically fetch until the done channel is closed. When the done channel is closed all MetricSet workers will stop and the returned output channel will be closed.

The returned channel is buffered with a length one one. It must drained to prevent blocking the operation of the MetricSets.

Start should be called only once in the life of a Wrapper.

func (*Wrapper) String

func (mw *Wrapper) String() string

String returns a string representation of Wrapper.

Jump to

Keyboard shortcuts

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