Skip to content

Commit

Permalink
Add only valid field types in cassandra input (#4048)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson authored Apr 19, 2018
1 parent 07760b2 commit 18cfb3f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugins/inputs/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
"io/ioutil"
"net/http"
"net/url"
"strings"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
)

type JolokiaClient interface {
Expand Down Expand Up @@ -60,7 +61,8 @@ func newCassandraMetric(host string, metric string,
func addValuesAsFields(values map[string]interface{}, fields map[string]interface{},
mname string) {
for k, v := range values {
if v != nil {
switch v.(type) {
case int64, float64, string, bool:
fields[mname+"_"+k] = v
}
}
Expand Down Expand Up @@ -117,7 +119,7 @@ func (j javaMetric) addTagsFields(out map[string]interface{}) {
switch t := values.(type) {
case map[string]interface{}:
addValuesAsFields(values.(map[string]interface{}), fields, attribute)
case interface{}:
case int64, float64, string, bool:
fields[attribute] = t
}
j.acc.AddFields(tokens["class"]+tokens["type"], fields, tags)
Expand Down

0 comments on commit 18cfb3f

Please sign in to comment.