Skip to content

Commit

Permalink
migrate docker provider to ECS fields: container.image -> container.i…
Browse files Browse the repository at this point in the history
…mage.name (#2411)

Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
(cherry picked from commit 3d73887)
  • Loading branch information
tetianakravchenko authored and mergify[bot] committed Mar 29, 2023
1 parent 509a95f commit a35b67e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
16 changes: 9 additions & 7 deletions internal/pkg/composable/providers/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,22 @@ func generateData(event bus.Event) (*dockerContainerData, error) {
container: container,
mapping: map[string]interface{}{
"container": map[string]interface{}{
"id": container.ID,
"name": container.Name,
"image": container.Image,
"id": container.ID,
"name": container.Name,
"image": map[string]interface{}{
"name": container.Image,
},
"labels": labelMap,
},
},
processors: []map[string]interface{}{
{
"add_fields": map[string]interface{}{
"fields": map[string]interface{}{
"id": container.ID,
"name": container.Name,
"image": container.Image,
"labels": processorLabelMap,
"id": container.ID,
"name": container.Name,
"image.name": container.Image,
"labels": processorLabelMap,
},
"target": "container",
},
Expand Down
19 changes: 11 additions & 8 deletions internal/pkg/composable/providers/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import (

func TestGenerateData(t *testing.T) {
container := &docker.Container{
ID: "abc",
Name: "foobar",
ID: "abc",
Name: "foobar",
Image: "busybox:latest",
Labels: map[string]string{
"do.not.include": "true",
"co.elastic.logs/disable": "true",
Expand All @@ -32,9 +33,11 @@ func TestGenerateData(t *testing.T) {
require.NoError(t, err)
mapping := map[string]interface{}{
"container": map[string]interface{}{
"id": container.ID,
"name": container.Name,
"image": container.Image,
"id": container.ID,
"name": container.Name,
"image": map[string]interface{}{
"name": container.Image,
},
"labels": mapstr.M{
"do": mapstr.M{"not": mapstr.M{"include": "true"}},
"co": mapstr.M{"elastic": mapstr.M{"logs/disable": "true"}},
Expand All @@ -45,9 +48,9 @@ func TestGenerateData(t *testing.T) {
{
"add_fields": map[string]interface{}{
"fields": map[string]interface{}{
"id": container.ID,
"name": container.Name,
"image": container.Image,
"id": container.ID,
"name": container.Name,
"image.name": container.Image,
"labels": mapstr.M{
"do_not_include": "true",
"co_elastic_logs/disable": "true",
Expand Down

0 comments on commit a35b67e

Please sign in to comment.