From 6c5a8f59304d18cf6f8e10a38cc482c74aa1d2c0 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Fri, 30 Aug 2019 14:48:12 +0200 Subject: [PATCH 1/2] Fix conversions of events with module fields (#13433) 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 #13432 (cherry picked from commit 310a96ef2995bec6b9865b6c1885c1ce3a7309da) --- metricbeat/module/kubernetes/container/container.go | 2 +- metricbeat/module/kubernetes/node/node.go | 2 +- metricbeat/module/kubernetes/pod/pod.go | 2 +- metricbeat/module/kubernetes/system/system.go | 2 +- metricbeat/module/kubernetes/volume/volume.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/metricbeat/module/kubernetes/container/container.go b/metricbeat/module/kubernetes/container/container.go index 4f0bbaaf386..ef9bb35d267 100644 --- a/metricbeat/module/kubernetes/container/container.go +++ b/metricbeat/module/kubernetes/container/container.go @@ -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 diff --git a/metricbeat/module/kubernetes/node/node.go b/metricbeat/module/kubernetes/node/node.go index 4d901d7e89c..cc545356dbd 100644 --- a/metricbeat/module/kubernetes/node/node.go +++ b/metricbeat/module/kubernetes/node/node.go @@ -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 } diff --git a/metricbeat/module/kubernetes/pod/pod.go b/metricbeat/module/kubernetes/pod/pod.go index 9cd3ff88621..b65a6a20b6d 100644 --- a/metricbeat/module/kubernetes/pod/pod.go +++ b/metricbeat/module/kubernetes/pod/pod.go @@ -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 } diff --git a/metricbeat/module/kubernetes/system/system.go b/metricbeat/module/kubernetes/system/system.go index 07625271d9f..28d17a2bb3a 100644 --- a/metricbeat/module/kubernetes/system/system.go +++ b/metricbeat/module/kubernetes/system/system.go @@ -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 } diff --git a/metricbeat/module/kubernetes/volume/volume.go b/metricbeat/module/kubernetes/volume/volume.go index df7b9dd594f..bc9ebb59140 100644 --- a/metricbeat/module/kubernetes/volume/volume.go +++ b/metricbeat/module/kubernetes/volume/volume.go @@ -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 From 03f466b0ec0a1e7a9c1374ed92fc4c5bdb786024 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Fri, 30 Aug 2019 15:27:55 +0200 Subject: [PATCH 2/2] Add missing changelog for #13433 --- CHANGELOG.next.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 7c819919322..e1064b7ddb3 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -180,6 +180,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] *Packetbeat*