Remove flush_scope logic
This commit is contained in:
parent
ff7e0f117d
commit
80fa87f197
|
@ -41,7 +41,6 @@ All measurements have the following tags:
|
||||||
|
|
||||||
```
|
```
|
||||||
# [[inputs.cgroup]]
|
# [[inputs.cgroup]]
|
||||||
# flush_scope = 10 # optional (the fields will be divided into parts of 10 items)
|
|
||||||
# paths = [
|
# paths = [
|
||||||
# "/cgroup/memory", # root cgroup
|
# "/cgroup/memory", # root cgroup
|
||||||
# "/cgroup/memory/child1", # container cgroup
|
# "/cgroup/memory/child1", # container cgroup
|
||||||
|
|
|
@ -18,9 +18,8 @@ import (
|
||||||
const metricName = "cgroup"
|
const metricName = "cgroup"
|
||||||
|
|
||||||
type CGroup struct {
|
type CGroup struct {
|
||||||
Paths []string `toml:"paths"`
|
Paths []string `toml:"paths"`
|
||||||
Files []string `toml:"fields"`
|
Files []string `toml:"fields"`
|
||||||
FlushScope int `toml:"flush_scope"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var sampleConfig = `
|
var sampleConfig = `
|
||||||
|
@ -83,31 +82,11 @@ func (g *CGroup) gatherDir(dir string, acc telegraf.Accumulator) error {
|
||||||
|
|
||||||
tags := map[string]string{"path": dir}
|
tags := map[string]string{"path": dir}
|
||||||
|
|
||||||
if g.FlushScope <= 0 {
|
acc.AddFields(metricName, fields, tags)
|
||||||
acc.AddFields(metricName, fields, tags)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
writeWithBatches(acc, fields, tags, g.FlushScope)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeWithBatches(acc telegraf.Accumulator, fields map[string]interface{}, tags map[string]string, scope int) {
|
|
||||||
for len(fields) > 0 {
|
|
||||||
batch := make(map[string]interface{})
|
|
||||||
|
|
||||||
for k, v := range fields {
|
|
||||||
batch[k] = v
|
|
||||||
delete(fields, k)
|
|
||||||
if len(batch) == scope || len(fields) == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
acc.AddFields(metricName, batch, tags)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
type pathInfo struct {
|
type pathInfo struct {
|
||||||
|
|
Loading…
Reference in New Issue