converter

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 9 Imported by: 9

README

Converter Processor

The converter processor is used to change the type of tag or field values. In addition to changing field types it can convert between fields and tags.

Values that cannot be converted are dropped.

Note: When converting tags to fields, take care to ensure the series is still uniquely identifiable. Fields with the same series key (measurement + tags) will overwrite one another.

Note on large strings being converted to numeric types: When converting a string value to a numeric type, precision may be lost if the number is too large. The largest numeric type this plugin supports is float64, and if a string 'number' exceeds its size limit, accuracy may be lost.

Configuration
# Convert values to another metric value type
[[processors.converter]]
  ## Tags to convert
  ##
  ## The table key determines the target type, and the array of key-values
  ## select the keys to convert.  The array may contain globs.
  ##   <target-type> = [<tag-key>...]
  [processors.converter.tags]
    measurement = []
    string = []
    integer = []
    unsigned = []
    boolean = []
    float = []

  ## Fields to convert
  ##
  ## The table key determines the target type, and the array of key-values
  ## select the keys to convert.  The array may contain globs.
  ##   <target-type> = [<field-key>...]
  [processors.converter.fields]
    measurement = []
    tag = []
    string = []
    integer = []
    unsigned = []
    boolean = []
    float = []
Example

Convert port tag to a string field:

[[processors.converter]]
  [processors.converter.tags]
    string = ["port"]
- apache,port=80,server=debian-stretch-apache BusyWorkers=1,BytesPerReq=0
+ apache,server=debian-stretch-apache port="80",BusyWorkers=1,BytesPerReq=0

Convert all scboard_* fields to an integer:

[[processors.converter]]
  [processors.converter.fields]
    integer = ["scboard_*"]
- apache scboard_closing=0,scboard_dnslookup=0,scboard_finishing=0,scboard_idle_cleanup=0,scboard_keepalive=0,scboard_logging=0,scboard_open=100,scboard_reading=0,scboard_sending=1,scboard_starting=0,scboard_waiting=49
+ apache scboard_closing=0i,scboard_dnslookup=0i,scboard_finishing=0i,scboard_idle_cleanup=0i,scboard_keepalive=0i,scboard_logging=0i,scboard_open=100i,scboard_reading=0i,scboard_sending=1i,scboard_starting=0i,scboard_waiting=49i

Rename the measurement from a tag value:

[[processors.converter]]
  [processors.converter.tags]
    measurement = ["topic"]
- mqtt_consumer,topic=sensor temp=42
+ sensor temp=42

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conversion

type Conversion struct {
	Measurement []string `toml:"measurement"`
	Tag         []string `toml:"tag"`
	String      []string `toml:"string"`
	Integer     []string `toml:"integer"`
	Unsigned    []string `toml:"unsigned"`
	Boolean     []string `toml:"boolean"`
	Float       []string `toml:"float"`
}

type ConversionFilter

type ConversionFilter struct {
	Measurement filter.Filter
	Tag         filter.Filter
	String      filter.Filter
	Integer     filter.Filter
	Unsigned    filter.Filter
	Boolean     filter.Filter
	Float       filter.Filter
}

type Converter

type Converter struct {
	Tags   *Conversion     `toml:"tags"`
	Fields *Conversion     `toml:"fields"`
	Log    telegraf.Logger `toml:"-"`
	// contains filtered or unexported fields
}

func (*Converter) Apply

func (p *Converter) Apply(metrics ...telegraf.Metric) []telegraf.Metric

func (*Converter) Description

func (p *Converter) Description() string

func (*Converter) Init

func (p *Converter) Init() error

func (*Converter) SampleConfig

func (p *Converter) SampleConfig() string

Jump to

Keyboard shortcuts

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