Skip to content

Commit

Permalink
Revert change about container.name and keep only the one about image.…
Browse files Browse the repository at this point in the history
…name

Signed-off-by: chrismark <chrismarkou92@gmail.com>
  • Loading branch information
ChrsMark committed Mar 10, 2021
1 parent e11ea81 commit 95c5ae9
Show file tree
Hide file tree
Showing 25 changed files with 413 additions and 423 deletions.
6 changes: 2 additions & 4 deletions auditbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -11970,12 +11970,10 @@ type: keyword
*`kubernetes.container.name`*::
+
--
Kubernetes container name
Kubernetes container name (different than the name from the runtime)
type: alias
alias to: container.name
type: keyword
--
Expand Down
2 changes: 1 addition & 1 deletion auditbeat/include/fields.go

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions filebeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -86569,12 +86569,10 @@ type: keyword
*`kubernetes.container.name`*::
+
--
Kubernetes container name
Kubernetes container name (different than the name from the runtime)


type: alias

alias to: container.name
type: keyword

--

Expand Down
2 changes: 1 addition & 1 deletion filebeat/include/fields.go

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions heartbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9552,12 +9552,10 @@ type: keyword
*`kubernetes.container.name`*::
+
--
Kubernetes container name
Kubernetes container name (different than the name from the runtime)
type: alias
alias to: container.name
type: keyword
--
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/include/fields.go

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions journalbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9897,12 +9897,10 @@ type: keyword
*`kubernetes.container.name`*::
+
--
Kubernetes container name
Kubernetes container name (different than the name from the runtime)
type: alias
alias to: container.name
type: keyword
--
Expand Down
2 changes: 1 addition & 1 deletion journalbeat/include/fields.go

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions libbeat/autodiscover/providers/kubernetes/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,14 @@ func (p *pod) emitEvents(pod *kubernetes.Pod, flag string, containers []kubernet
// so it works also on `stop` if containers have been already deleted.
eventID := fmt.Sprintf("%s.%s", pod.GetObjectMeta().GetUID(), c.Name)

meta := p.metagen.Generate(pod)
meta := p.metagen.Generate(pod, metadata.WithFields("container.name", c.Name))

cmeta := common.MapStr{
"id": cid,
"runtime": runtimes[c.Name],
"image": common.MapStr{
"name": c.Image,
},
"name": c.Name,
}

// Information that can be used in discovering a workload
Expand Down Expand Up @@ -386,7 +385,7 @@ func (p *pod) emitEvents(pod *kubernetes.Pod, flag string, containers []kubernet
"kubernetes": kubemeta,
//Actual metadata that will enrich the event
"meta": common.MapStr{
"kubernetes": meta, // these will be moved to ECS (container.name and container.image.name) through alias type
"kubernetes": meta,
"container": cmeta,
},
}
Expand Down
33 changes: 22 additions & 11 deletions libbeat/autodiscover/providers/kubernetes/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,14 @@ func TestEmitEvent(t *testing.T) {
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
"name": "filebeat",
},
},
"container": common.MapStr{
"image": common.MapStr{"name": "elastic/filebeat:6.3.0"},
"id": "foobar",
"runtime": "docker",
"name": "filebeat",
},
},
"config": []*common.Config{},
Expand Down Expand Up @@ -573,13 +574,14 @@ func TestEmitEvent(t *testing.T) {
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
"name": "filebeat",
},
},
"container": common.MapStr{
"image": common.MapStr{"name": "elastic/filebeat:6.3.0"},
"runtime": "docker",
"id": "foobar",
"name": "filebeat",
},
},
"config": []*common.Config{},
Expand Down Expand Up @@ -615,13 +617,14 @@ func TestEmitEvent(t *testing.T) {
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
"name": "filebeat",
},
},
"container": common.MapStr{
"image": common.MapStr{"name": "elastic/filebeat:6.3.0"},
"id": "foobar",
"runtime": "docker",
"name": "filebeat",
},
},
"config": []*common.Config{},
Expand Down Expand Up @@ -783,13 +786,14 @@ func TestEmitEvent(t *testing.T) {
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
"name": "filebeat",
},
},
"container": common.MapStr{
"image": common.MapStr{"name": "elastic/filebeat:6.3.0"},
"runtime": "",
"id": "",
"name": "filebeat",
},
},
"config": []*common.Config{},
Expand Down Expand Up @@ -888,13 +892,14 @@ func TestEmitEvent(t *testing.T) {
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
"name": "filebeat",
},
},
"container": common.MapStr{
"image": common.MapStr{"name": "elastic/filebeat:6.3.0"},
"id": "",
"runtime": "",
"name": "filebeat",
},
},
"config": []*common.Config{},
Expand Down Expand Up @@ -993,13 +998,14 @@ func TestEmitEvent(t *testing.T) {
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
"name": "filebeat",
},
},
"container": common.MapStr{
"image": common.MapStr{"name": "elastic/filebeat:6.3.0"},
"runtime": "",
"id": "",
"name": "filebeat",
},
},
"config": []*common.Config{},
Expand Down Expand Up @@ -1102,13 +1108,14 @@ func TestEmitEvent(t *testing.T) {
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
"name": "filebeat",
},
},
"container": common.MapStr{
"image": common.MapStr{"name": "elastic/filebeat:6.3.0"},
"id": "foobar",
"runtime": "docker",
"name": "filebeat",
},
},
"config": []*common.Config{},
Expand Down Expand Up @@ -1213,13 +1220,14 @@ func TestEmitEvent(t *testing.T) {
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
"name": "filebeat",
},
},
"container": common.MapStr{
"image": common.MapStr{"name": "elastic/filebeat:6.3.0"},
"id": "foobar",
"runtime": "docker",
"name": "filebeat",
},
},
"config": []*common.Config{},
Expand Down Expand Up @@ -1356,13 +1364,14 @@ func TestEmitEvent(t *testing.T) {
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
"name": "filebeat",
},
},
"container": common.MapStr{
"image": common.MapStr{"name": "elastic/filebeat:6.3.0"},
"id": "foobar",
"runtime": "docker",
"name": "filebeat",
},
},
"config": []*common.Config{},
Expand Down Expand Up @@ -1399,13 +1408,14 @@ func TestEmitEvent(t *testing.T) {
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
"name": "filebeat-init",
},
},
"container": common.MapStr{
"image": common.MapStr{"name": "elastic/filebeat:6.3.0"},
"id": "foobar-init",
"runtime": "docker",
"name": "filebeat-init",
},
},
"config": []*common.Config{},
Expand Down Expand Up @@ -1442,13 +1452,14 @@ func TestEmitEvent(t *testing.T) {
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
"name": "filebeat-ephemeral",
},
},
"container": common.MapStr{
"image": common.MapStr{"name": "elastic/filebeat:6.3.0"},
"id": "foobar-ephemeral",
"runtime": "docker",
"name": "filebeat-ephemeral",
},
},
"config": []*common.Config{},
Expand Down
5 changes: 2 additions & 3 deletions libbeat/processors/add_kubernetes_metadata/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@
Kubernetes statefulset name
- name: container.name
type: alias
path: container.name
type: keyword
description: >
Kubernetes container name
Kubernetes container name (different than the name from the runtime)
- name: container.image
type: alias
Expand Down
7 changes: 5 additions & 2 deletions libbeat/processors/add_kubernetes_metadata/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ func (k *kubernetesAnnotator) Run(event *beat.Event) (*beat.Event, error) {
}

metaClone := metadata.Clone()
containerImage, err := metaClone.GetValue("container.image")
metaClone.Delete("container.name")
containerImage, err := metadata.GetValue("container.image")
if err == nil {
metaClone.Delete("container.image")
metaClone.Put("container.image.name", containerImage)
Expand All @@ -271,7 +272,9 @@ func (k *kubernetesAnnotator) Run(event *beat.Event) (*beat.Event, error) {

kubeMeta := metadata.Clone()
// remove container meta from kubernetes.container.*
kubeMeta.Delete("container")
kubeMeta.Delete("container.id")
kubeMeta.Delete("container.runtime")
kubeMeta.Delete("container.image")
event.Fields.DeepUpdate(common.MapStr{
"kubernetes": kubeMeta,
})
Expand Down
6 changes: 2 additions & 4 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27465,12 +27465,10 @@ type: keyword
*`kubernetes.container.name`*::
+
--
Kubernetes container name
Kubernetes container name (different than the name from the runtime)


type: alias

alias to: container.name
type: keyword

--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"app": "playground"
},
"container": {
"name": "ubuntu",
"cpu": {
"request": {
"nanocores": 200000000
Expand Down Expand Up @@ -64,7 +65,6 @@
"image": {
"name": "ubuntu:latest"
},
"name": "ubuntu"
},
"event": {
"dataset": "kubernetes.container",
Expand Down
Loading

0 comments on commit 95c5ae9

Please sign in to comment.