Skip to content

Commit

Permalink
Merge pull request #118 from devopsext/SRE-3951
Browse files Browse the repository at this point in the history
Update Basicstats
  • Loading branch information
colixxx authored Sep 29, 2023
2 parents b11e723 + e5279a8 commit eadfdc6
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions plugins/aggregators/basicstats/basicstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ import (
var sampleConfig string

type BasicStats struct {
Stats []string `toml:"stats"`
Log telegraf.Logger
Stats []string `toml:"stats"`
CountSuffix string `toml:"count_suffix"`
MinSuffix string `toml:"min_suffix"`
MaxSuffix string `toml:"max_suffix"`
MeanSuffix string `toml:"mean_suffix"`
SumSuffix string `toml:"sum_suffix"`
Log telegraf.Logger

cache map[uint64]aggregate
statsConfig *configuredStats
Expand Down Expand Up @@ -157,19 +162,35 @@ func (b *BasicStats) Push(acc telegraf.Accumulator) {
fields := map[string]interface{}{}
for k, v := range aggregate.fields {
if b.statsConfig.count {
fields[k+"_count"] = v.count
fields[k+b.CountSuffix] = v.count
}
if b.statsConfig.min {
fields[k+"_min"] = v.min
fields[k+b.MinSuffix] = v.min
}
if b.statsConfig.max {
fields[k+"_max"] = v.max
fields[k+b.MaxSuffix] = v.max
}
if b.statsConfig.mean {
fields[k+"_mean"] = v.mean
fields[k+b.MeanSuffix] = v.mean
}
if b.statsConfig.sum {
fields[k+"_sum"] = v.sum
fields[k+b.SumSuffix] = v.sum
}

if b.statsConfig.count {
fields[k+b.CountSuffix] = v.count
}
if b.statsConfig.min {
fields[k+b.MinSuffix] = v.min
}
if b.statsConfig.max {
fields[k+b.MaxSuffix] = v.max
}
if b.statsConfig.mean {
fields[k+b.MeanSuffix] = v.mean
}
if b.statsConfig.sum {
fields[k+b.SumSuffix] = v.sum
}

//v.count always >=1
Expand Down

0 comments on commit eadfdc6

Please sign in to comment.