1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

View file

@ -0,0 +1,49 @@
package batch
import (
_ "embed"
"strconv"
"sync/atomic"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/processors"
)
//go:embed sample.conf
var sampleConfig string
type Batch struct {
BatchTag string `toml:"batch_tag"`
NumBatches uint64 `toml:"batches"`
SkipExisting bool `toml:"skip_existing"`
// the number of metrics that have been processed so far
count atomic.Uint64
}
func (*Batch) SampleConfig() string {
return sampleConfig
}
func (b *Batch) Apply(in ...telegraf.Metric) []telegraf.Metric {
out := make([]telegraf.Metric, 0, len(in))
for _, m := range in {
if b.SkipExisting && m.HasTag(b.BatchTag) {
out = append(out, m)
continue
}
oldCount := b.count.Add(1) - 1
batchID := oldCount % b.NumBatches
m.AddTag(b.BatchTag, strconv.FormatUint(batchID, 10))
out = append(out, m)
}
return out
}
func init() {
processors.Add("batch", func() telegraf.Processor {
return &Batch{}
})
}