diff --git a/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go b/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go index 6b912d17bb..987879f305 100644 --- a/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go +++ b/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go @@ -615,6 +615,9 @@ func InitializeScenario(ctx *godog.ScenarioContext) { ctx.Step(`^"([^"]*)" is ([a-z]*) with "([^"]*)"$`, func(name, state, option string) error { return pods.resourceIs(name, state, option) }) + ctx.Step(`^"([^"]*)" is ([a-z]*) with "([^"]*)" and "([^"]*)"$`, func(name, state, option1, option2 string) error { + return pods.resourceIs(name, state, option1, option2) + }) ctx.Step(`^"([^"]*)" collects events with "([^"]*:[^"]*)"$`, pods.collectsEventsWith) ctx.Step(`^"([^"]*)" does not collect events with "([^"]*)" during "([^"]*)"$`, pods.doesNotCollectEvents) diff --git a/e2e/_suites/kubernetes-autodiscover/features/filebeat.feature b/e2e/_suites/kubernetes-autodiscover/features/filebeat.feature index 7d01c0aece..04e54cdb90 100644 --- a/e2e/_suites/kubernetes-autodiscover/features/filebeat.feature +++ b/e2e/_suites/kubernetes-autodiscover/features/filebeat.feature @@ -36,9 +36,16 @@ Scenario: Logs collection from a pod with an ephemeral container When an ephemeral container is started in "a pod" Then "filebeat" collects events with "kubernetes.container.name:ephemeral-container" +# Running autodiscover with add_kubernetes_metadata is not recommended because both +# features add the same metadata, but there is nothing preventing this config. +Scenario: Logs collection from running pod and metadata enrichment using add_kubernetes_metadata + Given "filebeat" is running with "hints enabled" and "add_kubernetes_metadata" + When "a pod" is deployed + Then "filebeat" collects events with "kubernetes.pod.name:a-pod" + # Not really autodiscover, but this is a frequent use case in autodiscover-like # scenarios for logs collection. Scenario: Enrichment of normal input using add_kubernetes_metadata - Given "filebeat" is running with "input and add_kubernetes_metadata" + Given "filebeat" is running with "input with add_kubernetes_metadata" When "a pod" is deployed Then "filebeat" collects events with "kubernetes.pod.name:a-pod" diff --git a/e2e/_suites/kubernetes-autodiscover/testdata/templates/filebeat.yml.tmpl b/e2e/_suites/kubernetes-autodiscover/testdata/templates/filebeat.yml.tmpl index 513894cb59..05ae5d2b6f 100644 --- a/e2e/_suites/kubernetes-autodiscover/testdata/templates/filebeat.yml.tmpl +++ b/e2e/_suites/kubernetes-autodiscover/testdata/templates/filebeat.yml.tmpl @@ -7,7 +7,7 @@ metadata: k8s-app: filebeat data: filebeat.yml: |- -{{ if option "input and add_kubernetes_metadata" }} +{{ if option "input with add_kubernetes_metadata" }} filebeat.inputs: - type: container paths: @@ -31,6 +31,14 @@ data: paths: - /var/log/containers/*${data.kubernetes.container.id}.log {{ end }} +{{ end }} +{{ if option "add_kubernetes_metadata" }} + processors: + - add_kubernetes_metadata: + host: ${NODE_NAME} + matchers: + - logs_path: + logs_path: "/var/log/containers/" {{ end }} output.file: