enum

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: MIT Imports: 5 Imported by: 9

README

Enum Processor Plugin

The Enum Processor allows the configuration of value mappings for metric tags or fields. The main use-case for this is to rewrite status codes such as red, amber and green by numeric values such as 0, 1, 2. The plugin supports string, int, float64 and bool types for the field values. Multiple tags or fields can be configured with separate value mappings for each. Default mapping values can be configured to be used for all values, which are not contained in the value_mappings. The processor supports explicit configuration of a destination tag or field. By default the source tag or field is overwritten.

Configuration

[[processors.enum]]
  [[processors.enum.mapping]]
    ## Name of the field to map. Globs accepted.
    field = "status"

    ## Name of the tag to map. Globs accepted.
    # tag = "status"

    ## Destination tag or field to be used for the mapped value.  By default the
    ## source tag or field is used, overwriting the original value.
    dest = "status_code"

    ## Default value to be used for all values not contained in the mapping
    ## table.  When unset and no match is found, the original field will remain
    ## unmodified and the destination tag or field will not be created.
    # default = 0

    ## Table of mappings
    [processors.enum.mapping.value_mappings]
      green = 1
      amber = 2
      red = 3

Example

- xyzzy status="green" 1502489900000000000
+ xyzzy status="green",status_code=1i 1502489900000000000

With unknown value and no default set:

- xyzzy status="black" 1502489900000000000
+ xyzzy status="black" 1502489900000000000

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnumMapper

type EnumMapper struct {
	Mappings []Mapping `toml:"mapping"`

	FieldFilters map[string]filter.Filter
	TagFilters   map[string]filter.Filter
}

func (*EnumMapper) Apply

func (mapper *EnumMapper) Apply(in ...telegraf.Metric) []telegraf.Metric

func (*EnumMapper) Description

func (mapper *EnumMapper) Description() string

func (*EnumMapper) Init added in v1.17.0

func (mapper *EnumMapper) Init() error

func (*EnumMapper) SampleConfig

func (mapper *EnumMapper) SampleConfig() string

type Mapping

type Mapping struct {
	Tag           string
	Field         string
	Dest          string
	Default       interface{}
	ValueMappings map[string]interface{}
}

Jump to

Keyboard shortcuts

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