Skip to content

Commit

Permalink
сщььше
Browse files Browse the repository at this point in the history
  • Loading branch information
colixxxx committed Sep 8, 2023
1 parent a67e342 commit 7b67029
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,21 +162,37 @@ 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
if v.count > 1 {
variance := v.M2 / (v.count - 1)
Expand Down

0 comments on commit 7b67029

Please sign in to comment.