Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
47
plugins/processors/override/override.go
Normal file
47
plugins/processors/override/override.go
Normal file
|
@ -0,0 +1,47 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package override
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/plugins/processors"
|
||||
)
|
||||
|
||||
//go:embed sample.conf
|
||||
var sampleConfig string
|
||||
|
||||
type Override struct {
|
||||
NameOverride string `toml:"name_override"`
|
||||
NamePrefix string `toml:"name_prefix"`
|
||||
NameSuffix string `toml:"name_suffix"`
|
||||
Tags map[string]string `toml:"tags"`
|
||||
}
|
||||
|
||||
func (*Override) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (p *Override) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||
for _, metric := range in {
|
||||
if len(p.NameOverride) > 0 {
|
||||
metric.SetName(p.NameOverride)
|
||||
}
|
||||
if len(p.NamePrefix) > 0 {
|
||||
metric.AddPrefix(p.NamePrefix)
|
||||
}
|
||||
if len(p.NameSuffix) > 0 {
|
||||
metric.AddSuffix(p.NameSuffix)
|
||||
}
|
||||
for key, value := range p.Tags {
|
||||
metric.AddTag(key, value)
|
||||
}
|
||||
}
|
||||
return in
|
||||
}
|
||||
|
||||
func init() {
|
||||
processors.Add("override", func() telegraf.Processor {
|
||||
return &Override{}
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue