From 3d73887c9792b5756cdbf053c89d32e6dffc3c23 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Wed, 29 Mar 2023 12:36:31 +0200 Subject: [PATCH] migrate docker provider to ECS fields: container.image -> container.image.name (#2411) Signed-off-by: Tetiana Kravchenko --- .../pkg/composable/providers/docker/docker.go | 16 +++++++++------- .../providers/docker/docker_test.go | 19 +++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/internal/pkg/composable/providers/docker/docker.go b/internal/pkg/composable/providers/docker/docker.go index fa58b00a880..b64d247f425 100644 --- a/internal/pkg/composable/providers/docker/docker.go +++ b/internal/pkg/composable/providers/docker/docker.go @@ -131,9 +131,11 @@ 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, }, }, @@ -141,10 +143,10 @@ func generateData(event bus.Event) (*dockerContainerData, error) { { "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", }, diff --git a/internal/pkg/composable/providers/docker/docker_test.go b/internal/pkg/composable/providers/docker/docker_test.go index a035fe06a58..127ac901ab2 100644 --- a/internal/pkg/composable/providers/docker/docker_test.go +++ b/internal/pkg/composable/providers/docker/docker_test.go @@ -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", @@ -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"}}, @@ -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",