Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow floats in valuecounter aggregator. #5168

Merged
merged 1 commit into from
Dec 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions plugins/aggregators/valuecounter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
`originalfieldname_fieldvalue = count`.

Valuecounter only works on fields of the type int, bool or string. Float fields
are being dropped to prevent the creating of too many fields.
Counting fields with a high number of potential values may produce significant
amounts of new fields and memory usage, take care to only count fields with a
limited set of values.

### Configuration:

Expand Down
9 changes: 0 additions & 9 deletions plugins/aggregators/valuecounter/valuecounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package valuecounter

import (
"fmt"
"log"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/aggregators"
Expand Down Expand Up @@ -68,14 +67,6 @@ func (vc *ValueCounter) Add(in telegraf.Metric) {
for fk, fv := range in.Fields() {
for _, cf := range vc.Fields {
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)
vc.cache[id].fieldCount[fn]++
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/aggregators/valuecounter/valuecounter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ func NewTestValueCounter(fields []string) telegraf.Aggregator {
var m1, _ = metric.New("m1",
map[string]string{"foo": "bar"},
map[string]interface{}{
"status": 200,
"somefield": 20.1,
"foobar": "bar",
"status": 200,
"foobar": "bar",
},
time.Now(),
)
Expand Down