Remove Event field as it is causing issues with pre-trained source types (#8039)
Co-authored-by: Oleksii Samorukov <oleksii_samorukov@mckinsey.com>
This commit is contained in:
parent
ce133505f2
commit
191688ce51
|
|
@ -23,7 +23,6 @@ type CommonTags struct {
|
||||||
|
|
||||||
type HECTimeSeries struct {
|
type HECTimeSeries struct {
|
||||||
Time float64 `json:"time"`
|
Time float64 `json:"time"`
|
||||||
Event string `json:"event"`
|
|
||||||
Host string `json:"host,omitempty"`
|
Host string `json:"host,omitempty"`
|
||||||
Index string `json:"index,omitempty"`
|
Index string `json:"index,omitempty"`
|
||||||
Source string `json:"source,omitempty"`
|
Source string `json:"source,omitempty"`
|
||||||
|
|
@ -76,7 +75,6 @@ func (s *serializer) createMulti(metric telegraf.Metric, dataGroup HECTimeSeries
|
||||||
var metricJSON []byte
|
var metricJSON []byte
|
||||||
|
|
||||||
// Set the event data from the commonTags above.
|
// Set the event data from the commonTags above.
|
||||||
dataGroup.Event = "metric"
|
|
||||||
dataGroup.Time = commonTags.Time
|
dataGroup.Time = commonTags.Time
|
||||||
dataGroup.Host = commonTags.Host
|
dataGroup.Host = commonTags.Host
|
||||||
dataGroup.Index = commonTags.Index
|
dataGroup.Index = commonTags.Index
|
||||||
|
|
@ -131,8 +129,6 @@ func (s *serializer) createSingle(metric telegraf.Metric, dataGroup HECTimeSerie
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
dataGroup.Event = "metric"
|
|
||||||
|
|
||||||
dataGroup.Time = commonTags.Time
|
dataGroup.Time = commonTags.Time
|
||||||
|
|
||||||
// Apply the common tags from above to every record.
|
// Apply the common tags from above to every record.
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ func TestSerializeMetricFloatHec(t *testing.T) {
|
||||||
var buf []byte
|
var buf []byte
|
||||||
buf, err = s.Serialize(m)
|
buf, err = s.Serialize(m)
|
||||||
assert.NoError(t, err)
|
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))
|
assert.Equal(t, string(expS), string(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ func TestSerializeMetricIntHec(t *testing.T) {
|
||||||
buf, err = s.Serialize(m)
|
buf, err = s.Serialize(m)
|
||||||
assert.NoError(t, err)
|
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))
|
assert.Equal(t, string(expS), string(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,7 +132,7 @@ func TestSerializeMetricBoolHec(t *testing.T) {
|
||||||
buf, err = s.Serialize(m)
|
buf, err = s.Serialize(m)
|
||||||
assert.NoError(t, err)
|
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))
|
assert.Equal(t, string(expS), string(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -238,7 +238,7 @@ func TestSerializeBatchHec(t *testing.T) {
|
||||||
buf, err := s.SerializeBatch(metrics)
|
buf, err := s.SerializeBatch(metrics)
|
||||||
assert.NoError(t, err)
|
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))
|
assert.Equal(t, string(expS), string(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -260,6 +260,6 @@ func TestSerializeMultiHec(t *testing.T) {
|
||||||
buf, err := s.SerializeBatch(metrics)
|
buf, err := s.SerializeBatch(metrics)
|
||||||
assert.NoError(t, err)
|
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))
|
assert.Equal(t, string(expS), string(buf))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue