Skip to content

Commit

Permalink
Remove Event field as it is causing issues with pre-trained source ty…
Browse files Browse the repository at this point in the history
…pes (influxdata#8039)

Co-authored-by: Oleksii Samorukov <oleksii_samorukov@mckinsey.com>
  • Loading branch information
2 people authored and idohalevi committed Sep 23, 2020
1 parent 173d29e commit 3b1965f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 0 additions & 4 deletions plugins/serializers/splunkmetric/splunkmetric.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type CommonTags struct {

type HECTimeSeries struct {
Time float64 `json:"time"`
Event string `json:"event"`
Host string `json:"host,omitempty"`
Index string `json:"index,omitempty"`
Source string `json:"source,omitempty"`
Expand Down Expand Up @@ -76,7 +75,6 @@ func (s *serializer) createMulti(metric telegraf.Metric, dataGroup HECTimeSeries
var metricJSON []byte

// Set the event data from the commonTags above.
dataGroup.Event = "metric"
dataGroup.Time = commonTags.Time
dataGroup.Host = commonTags.Host
dataGroup.Index = commonTags.Index
Expand Down Expand Up @@ -131,8 +129,6 @@ func (s *serializer) createSingle(metric telegraf.Metric, dataGroup HECTimeSerie
continue
}

dataGroup.Event = "metric"

dataGroup.Time = commonTags.Time

// Apply the common tags from above to every record.
Expand Down
10 changes: 5 additions & 5 deletions plugins/serializers/splunkmetric/splunkmetric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,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,"cpu":"cpu0","metric_name":"cpu.usage_idle"}}`
expS := `{"time":1529875740.819,"fields":{"_value":91.5,"cpu":"cpu0","metric_name":"cpu.usage_idle"}}`
assert.Equal(t, string(expS), string(buf))
}

Expand Down Expand Up @@ -92,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,"cpu":"cpu0","metric_name":"cpu.usage_idle"}}`
expS := `{"time":0,"fields":{"_value":90,"cpu":"cpu0","metric_name":"cpu.usage_idle"}}`
assert.Equal(t, string(expS), string(buf))
}

Expand Down Expand Up @@ -132,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,"container-name":"telegraf-test","metric_name":"docker.oomkiller"}}`
expS := `{"time":0,"fields":{"_value":0,"container-name":"telegraf-test","metric_name":"docker.oomkiller"}}`
assert.Equal(t, string(expS), string(buf))
}

Expand Down Expand Up @@ -238,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,"metric_name":"cpu.value"}}{"time":0,"event":"metric","fields":{"_value":92,"metric_name":"cpu.value"}}`
expS := `{"time":0,"fields":{"_value":42,"metric_name":"cpu.value"}}{"time":0,"fields":{"_value":92,"metric_name":"cpu.value"}}`
assert.Equal(t, string(expS), string(buf))
}

Expand All @@ -260,6 +260,6 @@ func TestSerializeMultiHec(t *testing.T) {
buf, err := s.SerializeBatch(metrics)
assert.NoError(t, err)

expS := `{"time":0,"event":"metric","fields":{"metric_name:cpu.system":8,"metric_name:cpu.usage":42}}`
expS := `{"time":0,"fields":{"metric_name:cpu.system":8,"metric_name:cpu.usage":42}}`
assert.Equal(t, string(expS), string(buf))
}

0 comments on commit 3b1965f

Please sign in to comment.