chore: Embed sample configurations into README for processors (#11189)
This commit is contained in:
parent
d9a6d8b774
commit
e04d62dd16
4
Makefile
4
Makefile
|
|
@ -126,11 +126,11 @@ generate_plugins_%: build_generator
|
||||||
go generate -run="plugindata/main.go$$" ./plugins/$*/...
|
go generate -run="plugindata/main.go$$" ./plugins/$*/...
|
||||||
|
|
||||||
.PHONY: generate
|
.PHONY: generate
|
||||||
generate: insert_config_to_readme_inputs insert_config_to_readme_outputs generate_plugins_processors generate_plugins_aggregators
|
generate: insert_config_to_readme_inputs insert_config_to_readme_outputs insert_config_to_readme_processors generate_plugins_aggregators
|
||||||
|
|
||||||
.PHONY: generate-clean
|
.PHONY: generate-clean
|
||||||
generate-clean:
|
generate-clean:
|
||||||
go generate -run="plugindata/main.go --clean" ./plugins/processors/... ./plugins/aggregators/...
|
go generate -run="plugindata/main.go --clean" ./plugins/aggregators/...
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ to metrics associated with EC2 instances.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Attach AWS EC2 metadata to metrics
|
# Attach AWS EC2 metadata to metrics
|
||||||
[[processors.aws_ec2]]
|
[[processors.aws_ec2]]
|
||||||
## Instance identity document tags to attach to metrics.
|
## Instance identity document tags to attach to metrics.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
|
//go:generate ../../../../tools/readme_config_includer/generator
|
||||||
package ec2
|
package ec2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
_ "embed"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -20,6 +22,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type AwsEc2Processor struct {
|
type AwsEc2Processor struct {
|
||||||
ImdsTags []string `toml:"imds_tags"`
|
ImdsTags []string `toml:"imds_tags"`
|
||||||
EC2Tags []string `toml:"ec2_tags"`
|
EC2Tags []string `toml:"ec2_tags"`
|
||||||
|
|
@ -57,6 +63,10 @@ var allowedImdsTags = map[string]struct{}{
|
||||||
"version": {},
|
"version": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*AwsEc2Processor) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (r *AwsEc2Processor) Add(metric telegraf.Metric, _ telegraf.Accumulator) error {
|
func (r *AwsEc2Processor) Add(metric telegraf.Metric, _ telegraf.Accumulator) error {
|
||||||
r.parallel.Enqueue(metric)
|
r.parallel.Enqueue(metric)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package ec2
|
|
||||||
|
|
||||||
func (r *AwsEc2Processor) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -24,7 +24,7 @@ having several hosts (modifying ``host`` tag).
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Apply metric modifications using override semantics.
|
# Apply metric modifications using override semantics.
|
||||||
[[processors.clone]]
|
[[processors.clone]]
|
||||||
## All modifications on inputs and aggregators can be overridden:
|
## All modifications on inputs and aggregators can be overridden:
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,17 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package clone
|
package clone
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Clone struct {
|
type Clone struct {
|
||||||
NameOverride string
|
NameOverride string
|
||||||
NamePrefix string
|
NamePrefix string
|
||||||
|
|
@ -12,6 +19,10 @@ type Clone struct {
|
||||||
Tags map[string]string
|
Tags map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Clone) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Clone) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
func (c *Clone) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||||
cloned := []telegraf.Metric{}
|
cloned := []telegraf.Metric{}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package clone
|
|
||||||
|
|
||||||
func (c *Clone) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -13,7 +13,7 @@ will overwrite one another.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Convert values to another metric value type
|
# Convert values to another metric value type
|
||||||
[[processors.converter]]
|
[[processors.converter]]
|
||||||
## Tags to convert
|
## Tags to convert
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package converter
|
package converter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
|
@ -13,6 +15,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Conversion struct {
|
type Conversion struct {
|
||||||
Measurement []string `toml:"measurement"`
|
Measurement []string `toml:"measurement"`
|
||||||
Tag []string `toml:"tag"`
|
Tag []string `toml:"tag"`
|
||||||
|
|
@ -42,6 +48,10 @@ type ConversionFilter struct {
|
||||||
Float filter.Filter
|
Float filter.Filter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Converter) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Converter) Init() error {
|
func (p *Converter) Init() error {
|
||||||
return p.compile()
|
return p.compile()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package converter
|
|
||||||
|
|
||||||
func (p *Converter) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -12,7 +12,7 @@ A few example usecases include:
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Dates measurements, tags, and fields that pass through this filter.
|
# Dates measurements, tags, and fields that pass through this filter.
|
||||||
[[processors.date]]
|
[[processors.date]]
|
||||||
## New tag to create
|
## New tag to create
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package date
|
package date
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -9,6 +11,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
const defaultTimezone = "UTC"
|
const defaultTimezone = "UTC"
|
||||||
|
|
||||||
type Date struct {
|
type Date struct {
|
||||||
|
|
@ -21,6 +27,10 @@ type Date struct {
|
||||||
location *time.Location
|
location *time.Location
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Date) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Date) Init() error {
|
func (d *Date) Init() error {
|
||||||
// Check either TagKey or FieldKey specified
|
// Check either TagKey or FieldKey specified
|
||||||
if len(d.FieldKey) > 0 && len(d.TagKey) > 0 {
|
if len(d.FieldKey) > 0 && len(d.TagKey) > 0 {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package date
|
|
||||||
|
|
||||||
func (d *Date) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -4,7 +4,7 @@ Filter metrics whose field values are exact repetitions of the previous values.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Filter metrics with repeating field values
|
# Filter metrics with repeating field values
|
||||||
[[processors.dedup]]
|
[[processors.dedup]]
|
||||||
## Maximum time to suppress output
|
## Maximum time to suppress output
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package dedup
|
package dedup
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -8,6 +10,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Dedup struct {
|
type Dedup struct {
|
||||||
DedupInterval config.Duration `toml:"dedup_interval"`
|
DedupInterval config.Duration `toml:"dedup_interval"`
|
||||||
FlushTime time.Time
|
FlushTime time.Time
|
||||||
|
|
@ -36,6 +42,10 @@ func (d *Dedup) save(metric telegraf.Metric, id uint64) {
|
||||||
d.Cache[id].Accept()
|
d.Cache[id].Accept()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Dedup) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
// main processing method
|
// main processing method
|
||||||
func (d *Dedup) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
func (d *Dedup) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
||||||
idx := 0
|
idx := 0
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package dedup
|
|
||||||
|
|
||||||
func (d *Dedup) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -12,7 +12,7 @@ Telegraf minimum version: Telegraf 1.15.0
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
## Set default fields on your metric(s) when they are nil or empty
|
## Set default fields on your metric(s) when they are nil or empty
|
||||||
[[processors.defaults]]
|
[[processors.defaults]]
|
||||||
## Ensures a set of fields always exists on your metric(s) with their
|
## Ensures a set of fields always exists on your metric(s) with their
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,28 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package defaults
|
package defaults
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
// Defaults is a processor for ensuring certain fields always exist
|
// Defaults is a processor for ensuring certain fields always exist
|
||||||
// on your Metrics with at least a default value.
|
// on your Metrics with at least a default value.
|
||||||
type Defaults struct {
|
type Defaults struct {
|
||||||
DefaultFieldsSets map[string]interface{} `toml:"fields"`
|
DefaultFieldsSets map[string]interface{} `toml:"fields"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Defaults) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
// Apply contains the main implementation of this processor.
|
// Apply contains the main implementation of this processor.
|
||||||
// For each metric in 'inputMetrics', it goes over each default pair.
|
// For each metric in 'inputMetrics', it goes over each default pair.
|
||||||
// If the field in the pair does not exist on the metric, the associated default is added.
|
// If the field in the pair does not exist on the metric, the associated default is added.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package defaults
|
|
||||||
|
|
||||||
func (def *Defaults) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -11,7 +11,7 @@ source tag or field is overwritten.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Map enum values according to given table.
|
# Map enum values according to given table.
|
||||||
[[processors.enum]]
|
[[processors.enum]]
|
||||||
[[processors.enum.mapping]]
|
[[processors.enum.mapping]]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package enum
|
package enum
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
|
@ -9,6 +11,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type EnumMapper struct {
|
type EnumMapper struct {
|
||||||
Mappings []Mapping `toml:"mapping"`
|
Mappings []Mapping `toml:"mapping"`
|
||||||
|
|
||||||
|
|
@ -24,6 +30,10 @@ type Mapping struct {
|
||||||
ValueMappings map[string]interface{}
|
ValueMappings map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*EnumMapper) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (mapper *EnumMapper) Init() error {
|
func (mapper *EnumMapper) Init() error {
|
||||||
mapper.FieldFilters = make(map[string]filter.Filter)
|
mapper.FieldFilters = make(map[string]filter.Filter)
|
||||||
mapper.TagFilters = make(map[string]filter.Filter)
|
mapper.TagFilters = make(map[string]filter.Filter)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package enum
|
|
||||||
|
|
||||||
func (mapper *EnumMapper) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -22,7 +22,7 @@ Telegraf minimum version: Telegraf 1.15.0
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Run executable as long-running processor plugin
|
# Run executable as long-running processor plugin
|
||||||
[[processors.execd]]
|
[[processors.execd]]
|
||||||
## One program to run as daemon.
|
## One program to run as daemon.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package execd
|
package execd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
_ "embed"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
@ -17,6 +19,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/serializers"
|
"github.com/influxdata/telegraf/plugins/serializers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Execd struct {
|
type Execd struct {
|
||||||
Command []string `toml:"command"`
|
Command []string `toml:"command"`
|
||||||
Environment []string `toml:"environment"`
|
Environment []string `toml:"environment"`
|
||||||
|
|
@ -43,6 +49,10 @@ func New() *Execd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Execd) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (e *Execd) Start(acc telegraf.Accumulator) error {
|
func (e *Execd) Start(acc telegraf.Accumulator) error {
|
||||||
var err error
|
var err error
|
||||||
e.parser, err = parsers.NewParser(e.parserConfig)
|
e.parser, err = parsers.NewParser(e.parserConfig)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package execd
|
|
||||||
|
|
||||||
func (e *Execd) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -28,7 +28,7 @@ Telegraf minimum version: Telegraf 1.15.0
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Performs file path manipulations on tags and fields
|
# Performs file path manipulations on tags and fields
|
||||||
[[processors.filepath]]
|
[[processors.filepath]]
|
||||||
## Treat the tag value as a path and convert it to its last element, storing the result in a new tag
|
## Treat the tag value as a path and convert it to its last element, storing the result in a new tag
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package filepath
|
package filepath
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -8,6 +10,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
BaseName []BaseOpts `toml:"basename"`
|
BaseName []BaseOpts `toml:"basename"`
|
||||||
DirName []BaseOpts `toml:"dirname"`
|
DirName []BaseOpts `toml:"dirname"`
|
||||||
|
|
@ -95,6 +101,10 @@ func (o *Options) processMetric(metric telegraf.Metric) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Options) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (o *Options) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
func (o *Options) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||||
for _, m := range in {
|
for _, m := range in {
|
||||||
o.processMetric(m)
|
o.processMetric(m)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package filepath
|
|
||||||
|
|
||||||
func (o *Options) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -6,7 +6,7 @@ Telegraf minimum version: Telegraf 1.15.0
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Add a tag of the network interface name looked up over SNMP by interface number
|
# Add a tag of the network interface name looked up over SNMP by interface number
|
||||||
[[processors.ifname]]
|
[[processors.ifname]]
|
||||||
## Name of tag holding the interface number
|
## Name of tag holding the interface number
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package ifname
|
package ifname
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -15,6 +17,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type nameMap map[uint64]string
|
type nameMap map[uint64]string
|
||||||
type keyType = string
|
type keyType = string
|
||||||
type valType = nameMap
|
type valType = nameMap
|
||||||
|
|
@ -54,6 +60,10 @@ type IfName struct {
|
||||||
|
|
||||||
const minRetry = 5 * time.Minute
|
const minRetry = 5 * time.Minute
|
||||||
|
|
||||||
|
func (*IfName) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (d *IfName) Init() error {
|
func (d *IfName) Init() error {
|
||||||
d.getMapRemote = d.getMapRemoteNoMock
|
d.getMapRemote = d.getMapRemoteNoMock
|
||||||
d.makeTable = d.makeTableNoMock
|
d.makeTable = d.makeTableNoMock
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package ifname
|
|
||||||
|
|
||||||
func (d *IfName) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -7,7 +7,7 @@ Depending on the function, various parameters need to be configured:
|
||||||
|
|
||||||
Depending on the choice of the distribution function, the respective parameters must be set. Default settings are `noise_type = "laplacian"` with `mu = 0.0` and `scale = 1.0`:
|
Depending on the choice of the distribution function, the respective parameters must be set. Default settings are `noise_type = "laplacian"` with `mu = 0.0` and `scale = 1.0`:
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Adds noise to numerical fields
|
# Adds noise to numerical fields
|
||||||
[[processors.noise]]
|
[[processors.noise]]
|
||||||
## Specified the type of the random distribution.
|
## Specified the type of the random distribution.
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,23 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package noise
|
package noise
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"gonum.org/v1/gonum/stat/distuv"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/filter"
|
"github.com/influxdata/telegraf/filter"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
"gonum.org/v1/gonum/stat/distuv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultScale = 1.0
|
defaultScale = 1.0
|
||||||
defaultMin = -1.0
|
defaultMin = -1.0
|
||||||
|
|
@ -79,6 +86,10 @@ func (p *Noise) addNoise(value interface{}) interface{} {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Noise) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
// Creates a filter for Include and Exclude fields and sets the desired noise
|
// Creates a filter for Include and Exclude fields and sets the desired noise
|
||||||
// distribution
|
// distribution
|
||||||
func (p *Noise) Init() error {
|
func (p *Noise) Init() error {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package noise
|
|
||||||
|
|
||||||
func (p *Noise) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -23,7 +23,7 @@ are adhered to irrespective of input plugin configurations, e.g. by
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Apply metric modifications using override semantics.
|
# Apply metric modifications using override semantics.
|
||||||
[[processors.override]]
|
[[processors.override]]
|
||||||
## All modifications on inputs and aggregators can be overridden:
|
## All modifications on inputs and aggregators can be overridden:
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,17 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package override
|
package override
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Override struct {
|
type Override struct {
|
||||||
NameOverride string
|
NameOverride string
|
||||||
NamePrefix string
|
NamePrefix string
|
||||||
|
|
@ -12,6 +19,10 @@ type Override struct {
|
||||||
Tags map[string]string
|
Tags map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Override) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Override) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
func (p *Override) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||||
for _, metric := range in {
|
for _, metric := range in {
|
||||||
if len(p.NameOverride) > 0 {
|
if len(p.NameOverride) > 0 {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package override
|
|
||||||
|
|
||||||
func (p *Override) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -5,7 +5,7 @@ creates new metrics based on the contents of the field.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Parse a value in a specified field/tag(s) and add the result in a new metric
|
# Parse a value in a specified field/tag(s) and add the result in a new metric
|
||||||
[[processors.parser]]
|
[[processors.parser]]
|
||||||
## The name of the fields whose value will be parsed.
|
## The name of the fields whose value will be parsed.
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,19 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package parser
|
package parser
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/models"
|
"github.com/influxdata/telegraf/models"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers"
|
"github.com/influxdata/telegraf/plugins/parsers"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Parser struct {
|
type Parser struct {
|
||||||
parsers.Config
|
parsers.Config
|
||||||
DropOriginal bool `toml:"drop_original"`
|
DropOriginal bool `toml:"drop_original"`
|
||||||
|
|
@ -16,6 +23,10 @@ type Parser struct {
|
||||||
parser telegraf.Parser
|
parser telegraf.Parser
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Parser) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Parser) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
func (p *Parser) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
||||||
if p.parser == nil {
|
if p.parser == nil {
|
||||||
var err error
|
var err error
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package parser
|
|
||||||
|
|
||||||
func (p *Parser) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -10,7 +10,7 @@ To perform the reverse operation use the [unpivot] processor.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Rotate a single valued metric into a multi field metric
|
# Rotate a single valued metric into a multi field metric
|
||||||
[[processors.pivot]]
|
[[processors.pivot]]
|
||||||
## Tag to use for naming the new field.
|
## Tag to use for naming the new field.
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,26 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package pivot
|
package pivot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Pivot struct {
|
type Pivot struct {
|
||||||
TagKey string `toml:"tag_key"`
|
TagKey string `toml:"tag_key"`
|
||||||
ValueKey string `toml:"value_key"`
|
ValueKey string `toml:"value_key"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Pivot) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Pivot) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
func (p *Pivot) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
||||||
for _, m := range metrics {
|
for _, m := range metrics {
|
||||||
key, ok := m.GetTag(p.TagKey)
|
key, ok := m.GetTag(p.TagKey)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package pivot
|
|
||||||
|
|
||||||
func (p *Pivot) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -10,7 +10,7 @@ Telegraf minimum version: Telegraf 1.15.0
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Given a tag/field of a TCP or UDP port number, add a tag/field of the service name looked up in the system services file
|
# Given a tag/field of a TCP or UDP port number, add a tag/field of the service name looked up in the system services file
|
||||||
[[processors.port_name]]
|
[[processors.port_name]]
|
||||||
## Name of tag holding the port number
|
## Name of tag holding the port number
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package port_name
|
package port_name
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
_ "embed"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -11,6 +13,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type sMap map[string]map[int]string // "https" == services["tcp"][443]
|
type sMap map[string]map[int]string // "https" == services["tcp"][443]
|
||||||
|
|
||||||
var services sMap
|
var services sMap
|
||||||
|
|
@ -78,6 +84,10 @@ func readServices(r io.Reader) sMap {
|
||||||
return services
|
return services
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*PortName) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (pn *PortName) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
func (pn *PortName) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
||||||
for _, m := range metrics {
|
for _, m := range metrics {
|
||||||
var portProto string
|
var portProto string
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package port_name
|
|
||||||
|
|
||||||
func (pn *PortName) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -4,7 +4,7 @@ The printer processor plugin simple prints every metric passing through it.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Print all metrics that pass through this filter.
|
# Print all metrics that pass through this filter.
|
||||||
[[processors.printer]]
|
[[processors.printer]]
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package printer
|
package printer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -9,10 +11,18 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/serializers/influx"
|
"github.com/influxdata/telegraf/plugins/serializers/influx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Printer struct {
|
type Printer struct {
|
||||||
serializer serializers.Serializer
|
serializer serializers.Serializer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Printer) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Printer) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
func (p *Printer) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||||
for _, metric := range in {
|
for _, metric := range in {
|
||||||
octets, err := p.serializer.Serialize(metric)
|
octets, err := p.serializer.Serialize(metric)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package printer
|
|
||||||
|
|
||||||
func (p *Printer) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -11,7 +11,7 @@ For metrics transforms, `key` denotes the element that should be transformed. Fu
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Transforms tag and field values as well as measurement, tag and field names with regex pattern
|
# Transforms tag and field values as well as measurement, tag and field names with regex pattern
|
||||||
[[processors.regex]]
|
[[processors.regex]]
|
||||||
namepass = ["nginx_requests"]
|
namepass = ["nginx_requests"]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package regex
|
package regex
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
|
|
@ -9,6 +11,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Regex struct {
|
type Regex struct {
|
||||||
Tags []converter `toml:"tags"`
|
Tags []converter `toml:"tags"`
|
||||||
Fields []converter `toml:"fields"`
|
Fields []converter `toml:"fields"`
|
||||||
|
|
@ -27,6 +33,10 @@ type converter struct {
|
||||||
Append bool `toml:"append"`
|
Append bool `toml:"append"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Regex) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Regex) Init() error {
|
func (r *Regex) Init() error {
|
||||||
r.regexCache = make(map[string]*regexp.Regexp)
|
r.regexCache = make(map[string]*regexp.Regexp)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package regex
|
|
||||||
|
|
||||||
func (r *Regex) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -4,7 +4,7 @@ The `rename` processor renames measurements, fields, and tags.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Rename measurements, tags, and fields that pass through this filter.
|
# Rename measurements, tags, and fields that pass through this filter.
|
||||||
[[processors.rename]]
|
[[processors.rename]]
|
||||||
## Specify one sub-table per rename operation.
|
## Specify one sub-table per rename operation.
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,17 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package rename
|
package rename
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Replace struct {
|
type Replace struct {
|
||||||
Measurement string `toml:"measurement"`
|
Measurement string `toml:"measurement"`
|
||||||
Tag string `toml:"tag"`
|
Tag string `toml:"tag"`
|
||||||
|
|
@ -16,6 +23,10 @@ type Rename struct {
|
||||||
Replaces []Replace `toml:"replace"`
|
Replaces []Replace `toml:"replace"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Rename) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Rename) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
func (r *Rename) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||||
for _, point := range in {
|
for _, point := range in {
|
||||||
for _, replace := range r.Replaces {
|
for _, replace := range r.Replaces {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package rename
|
|
||||||
|
|
||||||
func (r *Rename) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -7,7 +7,7 @@ Telegraf minimum version: Telegraf 1.15.0
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# ReverseDNS does a reverse lookup on IP addresses to retrieve the DNS name
|
# ReverseDNS does a reverse lookup on IP addresses to retrieve the DNS name
|
||||||
[[processors.reverse_dns]]
|
[[processors.reverse_dns]]
|
||||||
## For optimal performance, you may want to limit which metrics are passed to this
|
## For optimal performance, you may want to limit which metrics are passed to this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package reverse_dns
|
package reverse_dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -9,6 +11,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type lookupEntry struct {
|
type lookupEntry struct {
|
||||||
Tag string `toml:"tag"`
|
Tag string `toml:"tag"`
|
||||||
Field string `toml:"field"`
|
Field string `toml:"field"`
|
||||||
|
|
@ -28,6 +34,10 @@ type ReverseDNS struct {
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*ReverseDNS) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (r *ReverseDNS) Start(acc telegraf.Accumulator) error {
|
func (r *ReverseDNS) Start(acc telegraf.Accumulator) error {
|
||||||
r.acc = acc
|
r.acc = acc
|
||||||
r.reverseDNSCache = NewReverseDNSCache(
|
r.reverseDNSCache = NewReverseDNSCache(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package reverse_dns
|
|
||||||
|
|
||||||
func (r *ReverseDNS) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -6,7 +6,7 @@ The `lat` and `lon` fields values should contain WGS-84 coordinates in decimal d
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Add the S2 Cell ID as a tag based on latitude and longitude fields
|
# Add the S2 Cell ID as a tag based on latitude and longitude fields
|
||||||
[[processors.s2geo]]
|
[[processors.s2geo]]
|
||||||
## The name of the lat and lon fields containing WGS-84 latitude and
|
## The name of the lat and lon fields containing WGS-84 latitude and
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,20 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package s2geo
|
package s2geo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/golang/geo/s2"
|
"github.com/golang/geo/s2"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Geo struct {
|
type Geo struct {
|
||||||
LatField string `toml:"lat_field"`
|
LatField string `toml:"lat_field"`
|
||||||
LonField string `toml:"lon_field"`
|
LonField string `toml:"lon_field"`
|
||||||
|
|
@ -15,6 +22,10 @@ type Geo struct {
|
||||||
CellLevel int `toml:"cell_level"`
|
CellLevel int `toml:"cell_level"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Geo) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Geo) Init() error {
|
func (g *Geo) Init() error {
|
||||||
if g.CellLevel < 0 || g.CellLevel > 30 {
|
if g.CellLevel < 0 || g.CellLevel > 30 {
|
||||||
return fmt.Errorf("invalid cell level %d", g.CellLevel)
|
return fmt.Errorf("invalid cell level %d", g.CellLevel)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package s2geo
|
|
||||||
|
|
||||||
func (g *Geo) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -16,7 +16,7 @@ Telegraf minimum version: Telegraf 1.15.0
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Process metrics using a Starlark script
|
# Process metrics using a Starlark script
|
||||||
[[processors.starlark]]
|
[[processors.starlark]]
|
||||||
## The Starlark source can be set as a string in this configuration file, or
|
## The Starlark source can be set as a string in this configuration file, or
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package starlark
|
package starlark
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -9,12 +11,20 @@ import (
|
||||||
"go.starlark.net/starlark"
|
"go.starlark.net/starlark"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Starlark struct {
|
type Starlark struct {
|
||||||
common.StarlarkCommon
|
common.StarlarkCommon
|
||||||
|
|
||||||
results []telegraf.Metric
|
results []telegraf.Metric
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Starlark) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Starlark) Init() error {
|
func (s *Starlark) Init() error {
|
||||||
err := s.StarlarkCommon.Init()
|
err := s.StarlarkCommon.Init()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package starlark
|
|
||||||
|
|
||||||
func (s *Starlark) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -27,7 +27,7 @@ If you'd like to apply multiple processings to the same `tag_key` or `field_key`
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Perform string processing on tags, fields, and measurements
|
# Perform string processing on tags, fields, and measurements
|
||||||
[[processors.strings]]
|
[[processors.strings]]
|
||||||
## Convert a field value to lowercase and store in a new field
|
## Convert a field value to lowercase and store in a new field
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package strings
|
package strings
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
@ -10,6 +12,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Strings struct {
|
type Strings struct {
|
||||||
Lowercase []converter `toml:"lowercase"`
|
Lowercase []converter `toml:"lowercase"`
|
||||||
Uppercase []converter `toml:"uppercase"`
|
Uppercase []converter `toml:"uppercase"`
|
||||||
|
|
@ -267,6 +273,10 @@ func (s *Strings) initOnce() {
|
||||||
s.init = true
|
s.init = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Strings) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Strings) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
func (s *Strings) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||||
s.initOnce()
|
s.initOnce()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package strings
|
|
||||||
|
|
||||||
func (s *Strings) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -10,7 +10,7 @@ levels of cardinality are computationally and/or financially expensive.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Restricts the number of tags that can pass through this filter and chooses which tags to preserve when over the limit.
|
# Restricts the number of tags that can pass through this filter and chooses which tags to preserve when over the limit.
|
||||||
[[processors.tag_limit]]
|
[[processors.tag_limit]]
|
||||||
## Maximum number of tags to preserve
|
## Maximum number of tags to preserve
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,18 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package tag_limit
|
package tag_limit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type TagLimit struct {
|
type TagLimit struct {
|
||||||
Limit int `toml:"limit"`
|
Limit int `toml:"limit"`
|
||||||
Keep []string `toml:"keep"`
|
Keep []string `toml:"keep"`
|
||||||
|
|
@ -31,6 +37,10 @@ func (d *TagLimit) initOnce() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*TagLimit) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (d *TagLimit) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
func (d *TagLimit) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||||
err := d.initOnce()
|
err := d.initOnce()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package tag_limit
|
|
||||||
|
|
||||||
func (d *TagLimit) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -12,7 +12,7 @@ Read the full [Go Template Documentation][].
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Uses a Go template to create a new tag
|
# Uses a Go template to create a new tag
|
||||||
[[processors.template]]
|
[[processors.template]]
|
||||||
## Tag to set with the output of the template.
|
## Tag to set with the output of the template.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package template
|
package template
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
|
@ -8,6 +10,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type TemplateProcessor struct {
|
type TemplateProcessor struct {
|
||||||
Tag string `toml:"tag"`
|
Tag string `toml:"tag"`
|
||||||
Template string `toml:"template"`
|
Template string `toml:"template"`
|
||||||
|
|
@ -15,6 +21,10 @@ type TemplateProcessor struct {
|
||||||
tmpl *template.Template
|
tmpl *template.Template
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*TemplateProcessor) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (r *TemplateProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
func (r *TemplateProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||||
// for each metric in "in" array
|
// for each metric in "in" array
|
||||||
for _, metric := range in {
|
for _, metric := range in {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package template
|
|
||||||
|
|
||||||
func (r *TemplateProcessor) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -17,7 +17,7 @@ Notes:
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Print all metrics that pass through this filter.
|
# Print all metrics that pass through this filter.
|
||||||
[[processors.topk]]
|
[[processors.topk]]
|
||||||
## How many seconds between aggregations
|
## How many seconds between aggregations
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package topk
|
package topk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
@ -13,6 +15,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type TopK struct {
|
type TopK struct {
|
||||||
Period config.Duration `toml:"period"`
|
Period config.Duration `toml:"period"`
|
||||||
K int `toml:"k"`
|
K int `toml:"k"`
|
||||||
|
|
@ -71,6 +77,10 @@ func sortMetrics(metrics []MetricAggregation, field string, reverse bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*TopK) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (t *TopK) Reset() {
|
func (t *TopK) Reset() {
|
||||||
t.cache = make(map[string][]telegraf.Metric)
|
t.cache = make(map[string][]telegraf.Metric)
|
||||||
t.lastAggregation = time.Now()
|
t.lastAggregation = time.Now()
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package topk
|
|
||||||
|
|
||||||
func (t *TopK) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
|
|
@ -6,7 +6,7 @@ To perform the reverse operation use the [pivot] processor.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# Rotate multi field metric into several single field metrics
|
# Rotate multi field metric into several single field metrics
|
||||||
[[processors.unpivot]]
|
[[processors.unpivot]]
|
||||||
## Tag to use for the name.
|
## Tag to use for the name.
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,17 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package unpivot
|
package unpivot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
|
||||||
|
//go:embed sample.conf
|
||||||
|
var sampleConfig string
|
||||||
|
|
||||||
type Unpivot struct {
|
type Unpivot struct {
|
||||||
TagKey string `toml:"tag_key"`
|
TagKey string `toml:"tag_key"`
|
||||||
ValueKey string `toml:"value_key"`
|
ValueKey string `toml:"value_key"`
|
||||||
|
|
@ -25,6 +32,10 @@ func copyWithoutFields(metric telegraf.Metric) telegraf.Metric {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Unpivot) SampleConfig() string {
|
||||||
|
return sampleConfig
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Unpivot) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
func (p *Unpivot) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
||||||
fieldCount := 0
|
fieldCount := 0
|
||||||
for _, m := range metrics {
|
for _, m := range metrics {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go
|
|
||||||
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
|
|
||||||
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
|
|
||||||
package unpivot
|
|
||||||
|
|
||||||
func (p *Unpivot) SampleConfig() string {
|
|
||||||
return `{{ .SampleConfig }}`
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue