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/$*/...
|
||||
|
||||
.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
|
||||
generate-clean:
|
||||
go generate -run="plugindata/main.go --clean" ./plugins/processors/... ./plugins/aggregators/...
|
||||
go generate -run="plugindata/main.go --clean" ./plugins/aggregators/...
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ to metrics associated with EC2 instances.
|
|||
|
||||
## Configuration
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Attach AWS EC2 metadata to metrics
|
||||
[[processors.aws_ec2]]
|
||||
## Instance identity document tags to attach to metrics.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
//go:generate ../../../../tools/readme_config_includer/generator
|
||||
package ec2
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
|
@ -20,6 +22,10 @@ import (
|
|||
"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 {
|
||||
ImdsTags []string `toml:"imds_tags"`
|
||||
EC2Tags []string `toml:"ec2_tags"`
|
||||
|
|
@ -57,6 +63,10 @@ var allowedImdsTags = map[string]struct{}{
|
|||
"version": {},
|
||||
}
|
||||
|
||||
func (*AwsEc2Processor) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (r *AwsEc2Processor) Add(metric telegraf.Metric, _ telegraf.Accumulator) error {
|
||||
r.parallel.Enqueue(metric)
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Apply metric modifications using override semantics.
|
||||
[[processors.clone]]
|
||||
## All modifications on inputs and aggregators can be overridden:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package clone
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"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 {
|
||||
NameOverride string
|
||||
NamePrefix string
|
||||
|
|
@ -12,6 +19,10 @@ type Clone struct {
|
|||
Tags map[string]string
|
||||
}
|
||||
|
||||
func (*Clone) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (c *Clone) Apply(in ...telegraf.Metric) []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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Convert values to another metric value type
|
||||
[[processors.converter]]
|
||||
## Tags to convert
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package converter
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
|
|
@ -13,6 +15,10 @@ import (
|
|||
"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 {
|
||||
Measurement []string `toml:"measurement"`
|
||||
Tag []string `toml:"tag"`
|
||||
|
|
@ -42,6 +48,10 @@ type ConversionFilter struct {
|
|||
Float filter.Filter
|
||||
}
|
||||
|
||||
func (*Converter) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (p *Converter) Init() error {
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Dates measurements, tags, and fields that pass through this filter.
|
||||
[[processors.date]]
|
||||
## New tag to create
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package date
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
|
|
@ -9,6 +11,10 @@ import (
|
|||
"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"
|
||||
|
||||
type Date struct {
|
||||
|
|
@ -21,6 +27,10 @@ type Date struct {
|
|||
location *time.Location
|
||||
}
|
||||
|
||||
func (*Date) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (d *Date) Init() error {
|
||||
// Check either TagKey or FieldKey specified
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Filter metrics with repeating field values
|
||||
[[processors.dedup]]
|
||||
## Maximum time to suppress output
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package dedup
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
|
|
@ -8,6 +10,10 @@ import (
|
|||
"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 {
|
||||
DedupInterval config.Duration `toml:"dedup_interval"`
|
||||
FlushTime time.Time
|
||||
|
|
@ -36,6 +42,10 @@ func (d *Dedup) save(metric telegraf.Metric, id uint64) {
|
|||
d.Cache[id].Accept()
|
||||
}
|
||||
|
||||
func (*Dedup) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
// main processing method
|
||||
func (d *Dedup) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
## Set default fields on your metric(s) when they are nil or empty
|
||||
[[processors.defaults]]
|
||||
## 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
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"strings"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"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
|
||||
// on your Metrics with at least a default value.
|
||||
type Defaults struct {
|
||||
DefaultFieldsSets map[string]interface{} `toml:"fields"`
|
||||
}
|
||||
|
||||
func (*Defaults) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
// Apply contains the main implementation of this processor.
|
||||
// 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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Map enum values according to given table.
|
||||
[[processors.enum]]
|
||||
[[processors.enum.mapping]]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package enum
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
|
|
@ -9,6 +11,10 @@ import (
|
|||
"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 {
|
||||
Mappings []Mapping `toml:"mapping"`
|
||||
|
||||
|
|
@ -24,6 +30,10 @@ type Mapping struct {
|
|||
ValueMappings map[string]interface{}
|
||||
}
|
||||
|
||||
func (*EnumMapper) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (mapper *EnumMapper) Init() error {
|
||||
mapper.FieldFilters = 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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Run executable as long-running processor plugin
|
||||
[[processors.execd]]
|
||||
## One program to run as daemon.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package execd
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
_ "embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
|
@ -17,6 +19,10 @@ import (
|
|||
"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 {
|
||||
Command []string `toml:"command"`
|
||||
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 {
|
||||
var err error
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Performs file path manipulations on tags and fields
|
||||
[[processors.filepath]]
|
||||
## 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
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
|
@ -8,6 +10,10 @@ import (
|
|||
"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 {
|
||||
BaseName []BaseOpts `toml:"basename"`
|
||||
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 {
|
||||
for _, m := range in {
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Add a tag of the network interface name looked up over SNMP by interface number
|
||||
[[processors.ifname]]
|
||||
## Name of tag holding the interface number
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package ifname
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
|
@ -15,6 +17,10 @@ import (
|
|||
"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 keyType = string
|
||||
type valType = nameMap
|
||||
|
|
@ -54,6 +60,10 @@ type IfName struct {
|
|||
|
||||
const minRetry = 5 * time.Minute
|
||||
|
||||
func (*IfName) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (d *IfName) Init() error {
|
||||
d.getMapRemote = d.getMapRemoteNoMock
|
||||
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`:
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Adds noise to numerical fields
|
||||
[[processors.noise]]
|
||||
## Specified the type of the random distribution.
|
||||
|
|
|
|||
|
|
@ -1,16 +1,23 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package noise
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
|
||||
"gonum.org/v1/gonum/stat/distuv"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/filter"
|
||||
"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 (
|
||||
defaultScale = 1.0
|
||||
defaultMin = -1.0
|
||||
|
|
@ -79,6 +86,10 @@ func (p *Noise) addNoise(value interface{}) interface{} {
|
|||
return value
|
||||
}
|
||||
|
||||
func (*Noise) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
// Creates a filter for Include and Exclude fields and sets the desired noise
|
||||
// distribution
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Apply metric modifications using override semantics.
|
||||
[[processors.override]]
|
||||
## All modifications on inputs and aggregators can be overridden:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package override
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"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 {
|
||||
NameOverride string
|
||||
NamePrefix string
|
||||
|
|
@ -12,6 +19,10 @@ type Override struct {
|
|||
Tags map[string]string
|
||||
}
|
||||
|
||||
func (*Override) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (p *Override) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||
for _, metric := range in {
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Parse a value in a specified field/tag(s) and add the result in a new metric
|
||||
[[processors.parser]]
|
||||
## The name of the fields whose value will be parsed.
|
||||
|
|
|
|||
|
|
@ -1,12 +1,19 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package parser
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/models"
|
||||
"github.com/influxdata/telegraf/plugins/parsers"
|
||||
"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 {
|
||||
parsers.Config
|
||||
DropOriginal bool `toml:"drop_original"`
|
||||
|
|
@ -16,6 +23,10 @@ type Parser struct {
|
|||
parser telegraf.Parser
|
||||
}
|
||||
|
||||
func (*Parser) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (p *Parser) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
||||
if p.parser == nil {
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Rotate a single valued metric into a multi field metric
|
||||
[[processors.pivot]]
|
||||
## Tag to use for naming the new field.
|
||||
|
|
|
|||
|
|
@ -1,15 +1,26 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package pivot
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"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 {
|
||||
TagKey string `toml:"tag_key"`
|
||||
ValueKey string `toml:"value_key"`
|
||||
}
|
||||
|
||||
func (*Pivot) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (p *Pivot) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
||||
for _, m := range metrics {
|
||||
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
|
||||
|
||||
```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
|
||||
[[processors.port_name]]
|
||||
## Name of tag holding the port number
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package port_name
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
_ "embed"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
|
|
@ -11,6 +13,10 @@ import (
|
|||
"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]
|
||||
|
||||
var services sMap
|
||||
|
|
@ -78,6 +84,10 @@ func readServices(r io.Reader) sMap {
|
|||
return services
|
||||
}
|
||||
|
||||
func (*PortName) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (pn *PortName) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
||||
for _, m := range metrics {
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Print all metrics that pass through this filter.
|
||||
[[processors.printer]]
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package printer
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
|
|
@ -9,10 +11,18 @@ import (
|
|||
"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 {
|
||||
serializer serializers.Serializer
|
||||
}
|
||||
|
||||
func (*Printer) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (p *Printer) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||
for _, metric := range in {
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Transforms tag and field values as well as measurement, tag and field names with regex pattern
|
||||
[[processors.regex]]
|
||||
namepass = ["nginx_requests"]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package regex
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
|
|
@ -9,6 +11,10 @@ import (
|
|||
"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 {
|
||||
Tags []converter `toml:"tags"`
|
||||
Fields []converter `toml:"fields"`
|
||||
|
|
@ -27,6 +33,10 @@ type converter struct {
|
|||
Append bool `toml:"append"`
|
||||
}
|
||||
|
||||
func (*Regex) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (r *Regex) Init() error {
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Rename measurements, tags, and fields that pass through this filter.
|
||||
[[processors.rename]]
|
||||
## Specify one sub-table per rename operation.
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package rename
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"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 {
|
||||
Measurement string `toml:"measurement"`
|
||||
Tag string `toml:"tag"`
|
||||
|
|
@ -16,6 +23,10 @@ type Rename struct {
|
|||
Replaces []Replace `toml:"replace"`
|
||||
}
|
||||
|
||||
func (*Rename) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (r *Rename) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||
for _, point := range in {
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# ReverseDNS does a reverse lookup on IP addresses to retrieve the DNS name
|
||||
[[processors.reverse_dns]]
|
||||
## 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
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
|
|
@ -9,6 +11,10 @@ import (
|
|||
"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 {
|
||||
Tag string `toml:"tag"`
|
||||
Field string `toml:"field"`
|
||||
|
|
@ -28,6 +34,10 @@ type ReverseDNS struct {
|
|||
Log telegraf.Logger `toml:"-"`
|
||||
}
|
||||
|
||||
func (*ReverseDNS) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (r *ReverseDNS) Start(acc telegraf.Accumulator) error {
|
||||
r.acc = acc
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Add the S2 Cell ID as a tag based on latitude and longitude fields
|
||||
[[processors.s2geo]]
|
||||
## 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
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
|
||||
"github.com/golang/geo/s2"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"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 {
|
||||
LatField string `toml:"lat_field"`
|
||||
LonField string `toml:"lon_field"`
|
||||
|
|
@ -15,6 +22,10 @@ type Geo struct {
|
|||
CellLevel int `toml:"cell_level"`
|
||||
}
|
||||
|
||||
func (*Geo) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (g *Geo) Init() error {
|
||||
if g.CellLevel < 0 || g.CellLevel > 30 {
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Process metrics using a Starlark script
|
||||
[[processors.starlark]]
|
||||
## 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
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
|
|
@ -9,12 +11,20 @@ import (
|
|||
"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 {
|
||||
common.StarlarkCommon
|
||||
|
||||
results []telegraf.Metric
|
||||
}
|
||||
|
||||
func (*Starlark) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (s *Starlark) Init() error {
|
||||
err := s.StarlarkCommon.Init()
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Perform string processing on tags, fields, and measurements
|
||||
[[processors.strings]]
|
||||
## 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
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
|
@ -10,6 +12,10 @@ import (
|
|||
"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 {
|
||||
Lowercase []converter `toml:"lowercase"`
|
||||
Uppercase []converter `toml:"uppercase"`
|
||||
|
|
@ -267,6 +273,10 @@ func (s *Strings) initOnce() {
|
|||
s.init = true
|
||||
}
|
||||
|
||||
func (*Strings) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (s *Strings) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||
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
|
||||
|
||||
```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.
|
||||
[[processors.tag_limit]]
|
||||
## Maximum number of tags to preserve
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package tag_limit
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"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 {
|
||||
Limit int `toml:"limit"`
|
||||
Keep []string `toml:"keep"`
|
||||
|
|
@ -31,6 +37,10 @@ func (d *TagLimit) initOnce() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (*TagLimit) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (d *TagLimit) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||
err := d.initOnce()
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Uses a Go template to create a new tag
|
||||
[[processors.template]]
|
||||
## Tag to set with the output of the template.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package template
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
|
|
@ -8,6 +10,10 @@ import (
|
|||
"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 {
|
||||
Tag string `toml:"tag"`
|
||||
Template string `toml:"template"`
|
||||
|
|
@ -15,6 +21,10 @@ type TemplateProcessor struct {
|
|||
tmpl *template.Template
|
||||
}
|
||||
|
||||
func (*TemplateProcessor) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (r *TemplateProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||
// for each metric in "in" array
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Print all metrics that pass through this filter.
|
||||
[[processors.topk]]
|
||||
## How many seconds between aggregations
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package topk
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
|
|
@ -13,6 +15,10 @@ import (
|
|||
"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 {
|
||||
Period config.Duration `toml:"period"`
|
||||
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() {
|
||||
t.cache = make(map[string][]telegraf.Metric)
|
||||
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
|
||||
|
||||
```toml
|
||||
```toml @sample.conf
|
||||
# Rotate multi field metric into several single field metrics
|
||||
[[processors.unpivot]]
|
||||
## Tag to use for the name.
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package unpivot
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"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 {
|
||||
TagKey string `toml:"tag_key"`
|
||||
ValueKey string `toml:"value_key"`
|
||||
|
|
@ -25,6 +32,10 @@ func copyWithoutFields(metric telegraf.Metric) telegraf.Metric {
|
|||
return m
|
||||
}
|
||||
|
||||
func (*Unpivot) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (p *Unpivot) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
|
||||
fieldCount := 0
|
||||
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