Allow floats in valuecounter aggregator (#5168)
This commit is contained in:
parent
c72d8a1663
commit
dbe6f594a9
|
@ -11,8 +11,9 @@ configuration directive. When no `fields` is provided the plugin will not count
|
||||||
any fields. The results are emitted in fields in the format:
|
any fields. The results are emitted in fields in the format:
|
||||||
`originalfieldname_fieldvalue = count`.
|
`originalfieldname_fieldvalue = count`.
|
||||||
|
|
||||||
Valuecounter only works on fields of the type int, bool or string. Float fields
|
Counting fields with a high number of potential values may produce significant
|
||||||
are being dropped to prevent the creating of too many fields.
|
amounts of new fields and memory usage, take care to only count fields with a
|
||||||
|
limited set of values.
|
||||||
|
|
||||||
### Configuration:
|
### Configuration:
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package valuecounter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/aggregators"
|
"github.com/influxdata/telegraf/plugins/aggregators"
|
||||||
|
@ -68,14 +67,6 @@ func (vc *ValueCounter) Add(in telegraf.Metric) {
|
||||||
for fk, fv := range in.Fields() {
|
for fk, fv := range in.Fields() {
|
||||||
for _, cf := range vc.Fields {
|
for _, cf := range vc.Fields {
|
||||||
if fk == cf {
|
if fk == cf {
|
||||||
// Do not process float types to prevent memory from blowing up
|
|
||||||
switch fv.(type) {
|
|
||||||
default:
|
|
||||||
log.Printf("I! Valuecounter: Unsupported field type. " +
|
|
||||||
"Must be an int, string or bool. Ignoring.")
|
|
||||||
continue
|
|
||||||
case uint64, int64, string, bool:
|
|
||||||
}
|
|
||||||
fn := fmt.Sprintf("%v_%v", fk, fv)
|
fn := fmt.Sprintf("%v_%v", fk, fv)
|
||||||
vc.cache[id].fieldCount[fn]++
|
vc.cache[id].fieldCount[fn]++
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ var m1, _ = metric.New("m1",
|
||||||
map[string]string{"foo": "bar"},
|
map[string]string{"foo": "bar"},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"somefield": 20.1,
|
|
||||||
"foobar": "bar",
|
"foobar": "bar",
|
||||||
},
|
},
|
||||||
time.Now(),
|
time.Now(),
|
||||||
|
|
Loading…
Reference in New Issue