From c3c9f3458a8035e8964abcc0a5217f2940414053 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Mon, 16 Mar 2020 16:51:12 +0100 Subject: [PATCH] Use default configuration in kubernetes metadata enrichers (#17020) Fix issues caused by dedotting not being enabled by default. --- CHANGELOG.next.asciidoc | 1 + libbeat/common/kubernetes/metadata/config.go | 2 +- libbeat/common/kubernetes/metadata/resource.go | 2 +- libbeat/common/kubernetes/metadata/resource_test.go | 2 +- metricbeat/module/kubernetes/util/kubernetes.go | 4 ++-- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 530931f6e7b..f4479918a87 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -11,6 +11,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d *Affecting all Beats* - Fix an issue that could cause redundant configuration reloads. {pull}16440[16440] +- Fix metadata enrichers to use default config for kubernetes module. {pull}17020[17020] *Auditbeat* diff --git a/libbeat/common/kubernetes/metadata/config.go b/libbeat/common/kubernetes/metadata/config.go index 78abe6d8e53..37dbcea718a 100644 --- a/libbeat/common/kubernetes/metadata/config.go +++ b/libbeat/common/kubernetes/metadata/config.go @@ -38,7 +38,7 @@ type AddResourceMetadataConfig struct { Namespace *common.Config `config:"namespace"` } -func defaultConfig() Config { +func DefaultConfig() Config { return Config{ IncludeCreatorMetadata: true, LabelsDedot: true, diff --git a/libbeat/common/kubernetes/metadata/resource.go b/libbeat/common/kubernetes/metadata/resource.go index e4610ce6b50..05ba3583c56 100644 --- a/libbeat/common/kubernetes/metadata/resource.go +++ b/libbeat/common/kubernetes/metadata/resource.go @@ -34,7 +34,7 @@ type Resource struct { // NewResourceMetadataGenerator creates a metadata generator for a generic resource func NewResourceMetadataGenerator(cfg *common.Config) *Resource { - config := defaultConfig() + config := DefaultConfig() config.Unmarshal(cfg) return &Resource{ diff --git a/libbeat/common/kubernetes/metadata/resource_test.go b/libbeat/common/kubernetes/metadata/resource_test.go index df79241c83a..dd8e043edd3 100644 --- a/libbeat/common/kubernetes/metadata/resource_test.go +++ b/libbeat/common/kubernetes/metadata/resource_test.go @@ -109,7 +109,7 @@ func TestResource_Generate(t *testing.T) { }, } - cfg := defaultConfig() + cfg := DefaultConfig() metagen := &Resource{ config: &cfg, } diff --git a/metricbeat/module/kubernetes/util/kubernetes.go b/metricbeat/module/kubernetes/util/kubernetes.go index 82b936c194c..e8888847727 100644 --- a/metricbeat/module/kubernetes/util/kubernetes.go +++ b/metricbeat/module/kubernetes/util/kubernetes.go @@ -116,7 +116,7 @@ func NewResourceMetadataEnricher( return &nilEnricher{} } - metaConfig := metadata.Config{} + metaConfig := metadata.DefaultConfig() if err := base.Module().UnpackConfig(&metaConfig); err != nil { logp.Err("Error initializing Kubernetes metadata enricher: %s", err) return &nilEnricher{} @@ -201,7 +201,7 @@ func NewContainerMetadataEnricher( return &nilEnricher{} } - metaConfig := metadata.Config{} + metaConfig := metadata.DefaultConfig() if err := base.Module().UnpackConfig(&metaConfig); err != nil { logp.Err("Error initializing Kubernetes metadata enricher: %s", err) return &nilEnricher{}