Skip to content

Commit

Permalink
Cherry-pick elastic#13433 to 7.4: Fix conversions of events with modu…
Browse files Browse the repository at this point in the history
…le fields (elastic#13440)

Metricsets that use special fields like `ModuleDataKey` cannot be
directly used as metricset fields of `mb.Event`, they need to be
converted using something like the `mb.TransformMapStrToEvent()`
helper.

Fix elastic#13432

(cherry picked from commit 71fb53e)
  • Loading branch information
jsoriano authored Aug 31, 2019
1 parent 0d06fb8 commit 0b46303
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix redis key metricset dashboard references to index pattern. {pull}13303[13303]
- Check if fields in DBInstance is nil in rds metricset. {pull}13294[13294] {issue}13037[13037]
- Fix silent failures in kafka and prometheus module. {pull}13353[13353] {issue}13252[13252]
- Fix module-level fields in Kubernetes metricsets. {pull}13433[13433]
- Fix panic in Redis Key metricset when collecting information from a removed key. {pull}13426[13426]

*Packetbeat*
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kubernetes/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) {
m.enricher.Enrich(events)

for _, e := range events {
reporter.Event(mb.Event{MetricSetFields: e})
reporter.Event(mb.TransformMapStrToEvent("kubernetes", e, nil))
}

return
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kubernetes/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) {

m.enricher.Enrich([]common.MapStr{event})

reporter.Event(mb.Event{MetricSetFields: event})
reporter.Event(mb.TransformMapStrToEvent("kubernetes", event, nil))

return
}
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kubernetes/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) {
m.enricher.Enrich(events)

for _, e := range events {
reporter.Event(mb.Event{MetricSetFields: e})
reporter.Event(mb.TransformMapStrToEvent("kubernetes", e, nil))
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kubernetes/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) {
}

for _, e := range events {
reporter.Event(mb.Event{MetricSetFields: e})
reporter.Event(mb.TransformMapStrToEvent("kubernetes", e, nil))
}
return
}
2 changes: 1 addition & 1 deletion metricbeat/module/kubernetes/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) {

events, err := eventMapping(body)
for _, e := range events {
reporter.Event(mb.Event{MetricSetFields: e})
reporter.Event(mb.TransformMapStrToEvent("kubernetes", e, nil))
}

return
Expand Down

0 comments on commit 0b46303

Please sign in to comment.