diff --git a/plugins/serializers/splunkmetric/README.md b/plugins/serializers/splunkmetric/README.md index 47ad8e1bf..96049e45f 100644 --- a/plugins/serializers/splunkmetric/README.md +++ b/plugins/serializers/splunkmetric/README.md @@ -38,8 +38,6 @@ you can send all of your CPU stats in one JSON struct, an example event looks li "event": "metric", "host": "mono.local", "fields": { - "_config_hecRouting": false, - "_config_multiMetric": true, "class": "osx", "cpu": "cpu0", "metric_name:telegraf.cpu.usage_guest": 0, diff --git a/plugins/serializers/splunkmetric/splunkmetric.go b/plugins/serializers/splunkmetric/splunkmetric.go index 77c724aa8..772771a10 100644 --- a/plugins/serializers/splunkmetric/splunkmetric.go +++ b/plugins/serializers/splunkmetric/splunkmetric.go @@ -179,12 +179,7 @@ func (s *serializer) createObject(metric telegraf.Metric) (metricGroup []byte, e // The tags are common to all events in this timeseries commonTags := CommonTags{} - commonObj := map[string]interface{}{} - - commonObj["config:hecRouting"] = s.HecRouting - commonObj["config:multiMetric"] = s.SplunkmetricMultiMetric - - commonTags.Fields = commonObj + commonTags.Fields = map[string]interface{}{} // Break tags out into key(n)=value(t) pairs for n, t := range metric.Tags() { diff --git a/plugins/serializers/splunkmetric/splunkmetric_test.go b/plugins/serializers/splunkmetric/splunkmetric_test.go index 70037e28a..5ce5265d8 100644 --- a/plugins/serializers/splunkmetric/splunkmetric_test.go +++ b/plugins/serializers/splunkmetric/splunkmetric_test.go @@ -4,10 +4,9 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" - "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/metric" + "github.com/stretchr/testify/assert" ) func MustMetric(v telegraf.Metric, err error) telegraf.Metric { @@ -33,7 +32,7 @@ func TestSerializeMetricFloat(t *testing.T) { var buf []byte buf, err = s.Serialize(m) assert.NoError(t, err) - expS := `{"_value":91.5,"config:hecRouting":false,"config:multiMetric":false,"cpu":"cpu0","metric_name":"cpu.usage_idle","time":1529875740.819}` + expS := `{"_value":91.5,"cpu":"cpu0","metric_name":"cpu.usage_idle","time":1529875740.819}` assert.Equal(t, string(expS), string(buf)) } @@ -53,7 +52,7 @@ func TestSerializeMetricFloatHec(t *testing.T) { var buf []byte buf, err = s.Serialize(m) assert.NoError(t, err) - expS := `{"time":1529875740.819,"event":"metric","fields":{"_value":91.5,"config:hecRouting":true,"config:multiMetric":false,"cpu":"cpu0","metric_name":"cpu.usage_idle"}}` + expS := `{"time":1529875740.819,"event":"metric","fields":{"_value":91.5,"cpu":"cpu0","metric_name":"cpu.usage_idle"}}` assert.Equal(t, string(expS), string(buf)) } @@ -73,7 +72,7 @@ func TestSerializeMetricInt(t *testing.T) { buf, err = s.Serialize(m) assert.NoError(t, err) - expS := `{"_value":90,"config:hecRouting":false,"config:multiMetric":false,"cpu":"cpu0","metric_name":"cpu.usage_idle","time":0}` + expS := `{"_value":90,"cpu":"cpu0","metric_name":"cpu.usage_idle","time":0}` assert.Equal(t, string(expS), string(buf)) } @@ -93,7 +92,7 @@ func TestSerializeMetricIntHec(t *testing.T) { buf, err = s.Serialize(m) assert.NoError(t, err) - expS := `{"time":0,"event":"metric","fields":{"_value":90,"config:hecRouting":true,"config:multiMetric":false,"cpu":"cpu0","metric_name":"cpu.usage_idle"}}` + expS := `{"time":0,"event":"metric","fields":{"_value":90,"cpu":"cpu0","metric_name":"cpu.usage_idle"}}` assert.Equal(t, string(expS), string(buf)) } @@ -113,7 +112,7 @@ func TestSerializeMetricBool(t *testing.T) { buf, err = s.Serialize(m) assert.NoError(t, err) - expS := `{"_value":1,"config:hecRouting":false,"config:multiMetric":false,"container-name":"telegraf-test","metric_name":"docker.oomkiller","time":0}` + expS := `{"_value":1,"container-name":"telegraf-test","metric_name":"docker.oomkiller","time":0}` assert.Equal(t, string(expS), string(buf)) } @@ -133,7 +132,7 @@ func TestSerializeMetricBoolHec(t *testing.T) { buf, err = s.Serialize(m) assert.NoError(t, err) - expS := `{"time":0,"event":"metric","fields":{"_value":0,"config:hecRouting":true,"config:multiMetric":false,"container-name":"telegraf-test","metric_name":"docker.oomkiller"}}` + expS := `{"time":0,"event":"metric","fields":{"_value":0,"container-name":"telegraf-test","metric_name":"docker.oomkiller"}}` assert.Equal(t, string(expS), string(buf)) } @@ -154,7 +153,7 @@ func TestSerializeMetricString(t *testing.T) { buf, err = s.Serialize(m) assert.NoError(t, err) - expS := `{"_value":5,"config:hecRouting":false,"config:multiMetric":false,"cpu":"cpu0","metric_name":"cpu.usage_idle","time":0}` + expS := `{"_value":5,"cpu":"cpu0","metric_name":"cpu.usage_idle","time":0}` assert.Equal(t, string(expS), string(buf)) assert.NoError(t, err) } @@ -186,7 +185,7 @@ func TestSerializeBatch(t *testing.T) { buf, err := s.SerializeBatch(metrics) assert.NoError(t, err) - expS := `{"_value":42,"config:hecRouting":false,"config:multiMetric":false,"metric_name":"cpu.value","time":0}{"_value":92,"config:hecRouting":false,"config:multiMetric":false,"metric_name":"cpu.value","time":0}` + expS := `{"_value":42,"metric_name":"cpu.value","time":0}{"_value":92,"metric_name":"cpu.value","time":0}` assert.Equal(t, string(expS), string(buf)) } @@ -208,7 +207,7 @@ func TestSerializeMulti(t *testing.T) { buf, err := s.SerializeBatch(metrics) assert.NoError(t, err) - expS := `{"config:hecRouting":false,"config:multiMetric":true,"metric_name:cpu.system":8,"metric_name:cpu.user":42,"time":0}` + expS := `{"metric_name:cpu.system":8,"metric_name:cpu.user":42,"time":0}` assert.Equal(t, string(expS), string(buf)) } @@ -239,7 +238,7 @@ func TestSerializeBatchHec(t *testing.T) { buf, err := s.SerializeBatch(metrics) assert.NoError(t, err) - expS := `{"time":0,"event":"metric","fields":{"_value":42,"config:hecRouting":true,"config:multiMetric":false,"metric_name":"cpu.value"}}{"time":0,"event":"metric","fields":{"_value":92,"config:hecRouting":true,"config:multiMetric":false,"metric_name":"cpu.value"}}` + expS := `{"time":0,"event":"metric","fields":{"_value":42,"metric_name":"cpu.value"}}{"time":0,"event":"metric","fields":{"_value":92,"metric_name":"cpu.value"}}` assert.Equal(t, string(expS), string(buf)) } @@ -261,6 +260,6 @@ func TestSerializeMultiHec(t *testing.T) { buf, err := s.SerializeBatch(metrics) assert.NoError(t, err) - expS := `{"time":0,"event":"metric","fields":{"config:hecRouting":true,"config:multiMetric":true,"metric_name:cpu.system":8,"metric_name:cpu.usage":42}}` + expS := `{"time":0,"event":"metric","fields":{"metric_name:cpu.system":8,"metric_name:cpu.usage":42}}` assert.Equal(t, string(expS), string(buf)) }