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
34
models/makemetric.go
Normal file
34
models/makemetric.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"github.com/influxdata/telegraf"
|
||||
)
|
||||
|
||||
// makeMetric applies new metric plugin and agent measurement and tag settings.
|
||||
func makeMetric(metric telegraf.Metric, nameOverride, namePrefix, nameSuffix string, tags, globalTags map[string]string) telegraf.Metric {
|
||||
if len(nameOverride) != 0 {
|
||||
metric.SetName(nameOverride)
|
||||
}
|
||||
|
||||
if len(namePrefix) != 0 {
|
||||
metric.AddPrefix(namePrefix)
|
||||
}
|
||||
if len(nameSuffix) != 0 {
|
||||
metric.AddSuffix(nameSuffix)
|
||||
}
|
||||
|
||||
// Apply plugin-wide tags
|
||||
for k, v := range tags {
|
||||
if _, ok := metric.GetTag(k); !ok {
|
||||
metric.AddTag(k, v)
|
||||
}
|
||||
}
|
||||
// Apply global tags
|
||||
for k, v := range globalTags {
|
||||
if _, ok := metric.GetTag(k); !ok {
|
||||
metric.AddTag(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
return metric
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue