diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 82b2dc72049..14850c8d419 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -21,6 +21,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Rename `process.exe` to `process.executable` in add_process_metadata to align with ECS. {pull}9949[9949] - Import ECS change https://github.com/elastic/ecs/pull/308[ecs#308]: leaf field `user.group` is now the `group` field set. {pull}10275[10275] +- Docker and Kubernetes labels/annotations will be "dedoted" by default. {pull}10338[10338] *Auditbeat* - Rename `process.exe` to `process.executable` in auditd module to align with ECS. {pull}9949[9949] diff --git a/libbeat/common/kubernetes/metadata.go b/libbeat/common/kubernetes/metadata.go index d9698daad99..ad53378abac 100644 --- a/libbeat/common/kubernetes/metadata.go +++ b/libbeat/common/kubernetes/metadata.go @@ -55,8 +55,8 @@ func NewMetaGenerator(cfg *common.Config) (MetaGenerator, error) { // default settings: generator := metaGenerator{ IncludeCreatorMetadata: true, - LabelsDedot: false, - AnnotationsDedot: false, + LabelsDedot: true, + AnnotationsDedot: true, } err := cfg.Unpack(&generator) diff --git a/libbeat/common/kubernetes/metadata_test.go b/libbeat/common/kubernetes/metadata_test.go index a4717eb2fe4..8d0cd301a3e 100644 --- a/libbeat/common/kubernetes/metadata_test.go +++ b/libbeat/common/kubernetes/metadata_test.go @@ -35,9 +35,8 @@ func TestPodMetadata(t *testing.T) { True := true False := false tests := []struct { - pod *Pod - meta common.MapStr - config *common.Config + pod *Pod + meta common.MapStr }{ { pod: &Pod{ @@ -59,7 +58,6 @@ func TestPodMetadata(t *testing.T) { "namespace": "test", "labels": common.MapStr{"a": common.MapStr{"value": "bar", "key": "foo"}}, }, - config: common.NewConfig(), }, { pod: &Pod{ @@ -92,12 +90,17 @@ func TestPodMetadata(t *testing.T) { "labels": common.MapStr{"a": common.MapStr{"value": "bar", "key": "foo"}}, "deployment": common.MapStr{"name": "test"}, }, - config: common.NewConfig(), }, } for _, test := range tests { - metaGen, err := NewMetaGenerator(test.config) + config, err := common.NewConfigFrom(map[string]interface{}{ + "labels.dedot": false, + "annotations.dedot": false, + "include_annotations": []string{"b", "b.key"}, + }) + + metaGen, err := NewMetaGenerator(config) if err != nil { t.Fatal(err) } @@ -113,9 +116,8 @@ func TestPodMetadataDeDot(t *testing.T) { True := true False := false tests := []struct { - pod *Pod - meta common.MapStr - config *common.Config + pod *Pod + meta common.MapStr }{ { pod: &Pod{ @@ -139,7 +141,6 @@ func TestPodMetadataDeDot(t *testing.T) { "labels": common.MapStr{"a": "bar", "a_key": "foo"}, "annotations": common.MapStr{"b": "bar", "b_key": "foo"}, }, - config: common.NewConfig(), }, { pod: &Pod{ @@ -172,14 +173,11 @@ func TestPodMetadataDeDot(t *testing.T) { "labels": common.MapStr{"a": "bar", "a_key": "foo"}, "deployment": common.MapStr{"name": "test"}, }, - config: common.NewConfig(), }, } for _, test := range tests { config, err := common.NewConfigFrom(map[string]interface{}{ - "labels.dedot": true, - "annotations.dedot": true, "include_annotations": []string{"b", "b.key"}, }) metaGen, err := NewMetaGenerator(config) diff --git a/libbeat/processors/add_docker_metadata/add_docker_metadata_test.go b/libbeat/processors/add_docker_metadata/add_docker_metadata_test.go index 719e95556bf..385951765e6 100644 --- a/libbeat/processors/add_docker_metadata/add_docker_metadata_test.go +++ b/libbeat/processors/add_docker_metadata/add_docker_metadata_test.go @@ -104,6 +104,7 @@ func TestMatchNoContainer(t *testing.T) { func TestMatchContainer(t *testing.T) { testConfig, err := common.NewConfigFrom(map[string]interface{}{ "match_fields": []string{"foo"}, + "labels.dedot": false, }) assert.NoError(t, err) @@ -152,7 +153,6 @@ func TestMatchContainer(t *testing.T) { func TestMatchContainerWithDedot(t *testing.T) { testConfig, err := common.NewConfigFrom(map[string]interface{}{ "match_fields": []string{"foo"}, - "labels.dedot": true, }) assert.NoError(t, err) diff --git a/libbeat/processors/add_docker_metadata/config.go b/libbeat/processors/add_docker_metadata/config.go index dc1a3d4fc89..aa78dd08ca0 100644 --- a/libbeat/processors/add_docker_metadata/config.go +++ b/libbeat/processors/add_docker_metadata/config.go @@ -46,6 +46,6 @@ func defaultConfig() Config { MatchSource: true, SourceIndex: 4, // Use 4 to match the CID in /var/lib/docker/containers//*.log. MatchPIDs: []string{"process.pid", "process.ppid"}, - DeDot: false, + DeDot: true, } } diff --git a/metricbeat/module/kubernetes/_meta/config.yml b/metricbeat/module/kubernetes/_meta/config.yml index ec678aa79b5..e0d140ddaa8 100644 --- a/metricbeat/module/kubernetes/_meta/config.yml +++ b/metricbeat/module/kubernetes/_meta/config.yml @@ -17,8 +17,8 @@ # Enriching parameters: #add_metadata: true #in_cluster: true - #labels.dedot: false - #annotations.dedot: false + #labels.dedot: true + #annotations.dedot: true # When used outside the cluster: #in_cluster: false #host: node_name diff --git a/metricbeat/module/kubernetes/event/config.go b/metricbeat/module/kubernetes/event/config.go index daabe2b292e..93cf663eca8 100644 --- a/metricbeat/module/kubernetes/event/config.go +++ b/metricbeat/module/kubernetes/event/config.go @@ -39,8 +39,8 @@ func defaultKubernetesEventsConfig() kubeEventsConfig { return kubeEventsConfig{ InCluster: true, SyncPeriod: 1 * time.Second, - LabelsDedot: false, - AnnotationsDedot: false, + LabelsDedot: true, + AnnotationsDedot: true, } } diff --git a/metricbeat/module/kubernetes/event/event.go b/metricbeat/module/kubernetes/event/event.go index 2d10068d8a5..defdb9857bd 100644 --- a/metricbeat/module/kubernetes/event/event.go +++ b/metricbeat/module/kubernetes/event/event.go @@ -46,7 +46,8 @@ type MetricSet struct { } // dedotConfig defines LabelsDedot and AnnotationsDedot. -// Default to be false. If set to true, replace dots in labels with `_`. +// If set to true, replace dots in labels with `_`. +// Default to be true. type dedotConfig struct { LabelsDedot bool `config:"labels.dedot"` AnnotationsDedot bool `config:"annotations.dedot"` diff --git a/metricbeat/modules.d/kubernetes.yml.disabled b/metricbeat/modules.d/kubernetes.yml.disabled index 38b08c8e05d..6ef57d33225 100644 --- a/metricbeat/modules.d/kubernetes.yml.disabled +++ b/metricbeat/modules.d/kubernetes.yml.disabled @@ -20,8 +20,8 @@ # Enriching parameters: #add_metadata: true #in_cluster: true - #labels.dedot: false - #annotations.dedot: false + #labels.dedot: true + #annotations.dedot: true # When used outside the cluster: #in_cluster: false #host: node_name