From 121edbf9f62c1ed9659dd483f0dfc3deaa1bef3f 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 4f0bbaaf3864..ef9bb35d2672 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 4d901d7e89c6..cc545356dbd1 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 9cd3ff886215..b65a6a20b6d4 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 07625271d9fa..28d17a2bb3a8 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 df7b9dd594f0..bc9ebb59140d 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 95c05b227d1c5859f3d97310fb68e93d3d89ea9f 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 732a050b8540..4a6b5949607a 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -45,6 +45,7 @@ https://github.com/elastic/beats/compare/v7.2.0...7.2[Check the HEAD diff] *Metricbeat* - Print errors that were being omitted in vSphere metricsets {pull}12816[12816] +- Fix module-level fields in Kubernetes metricsets. {pull}13433[13433] *Packetbeat*