From 4bd2d49a16530aee671a8b85781504c84b166bed Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Sun, 24 Mar 2024 18:02:49 -0700 Subject: [PATCH] Fix docker observer --- .../docker_observer_discovery_test.go | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/general/discoverymode/docker_observer_discovery_test.go b/tests/general/discoverymode/docker_observer_discovery_test.go index 8e2abc7bf5..0a4a81528a 100644 --- a/tests/general/discoverymode/docker_observer_discovery_test.go +++ b/tests/general/discoverymode/docker_observer_discovery_test.go @@ -152,6 +152,11 @@ func TestDockerObserver(t *testing.T) { "resource_attributes": map[string]any{}, "rule": `type == "container" and labels['test.id'] == '${SPLUNK_TEST_ID}' and port == 9090`, }, + "redis": map[string]any{ + "config": map[string]any{}, + "resource_attributes": map[string]any{}, + "rule": "type == \"container\" and any([name, image, command], {# matches \"(?i)redis\"}) and not (command matches \"splunk.discovery\")", + }, }, "watch_observers": []any{"docker_observer"}, }, @@ -228,6 +233,11 @@ func TestDockerObserver(t *testing.T) { "resource_attributes": map[string]any{}, "rule": fmt.Sprintf(`type == "container" and labels['test.id'] == '%s' and port == 9090`, tc.ID), }, + "redis": map[string]any{ + "config": map[string]any{}, + "resource_attributes": map[string]any{}, + "rule": "type == \"container\" and any([name, image, command], {# matches \"(?i)redis\"}) and not (command matches \"splunk.discovery\")", + }, }, "watch_observers": []any{"docker_observer"}, }, @@ -277,6 +287,11 @@ receivers: resource_attributes: {} rule: type == "container" and labels['test.id'] == '${SPLUNK_TEST_ID}' and port == 9090 + redis: + config: {} + resource_attributes: {} + rule: type == "container" and any([name, image, command], {# matches "(?i)redis"}) + and not (command matches "splunk.discovery") watch_observers: - docker_observer service: @@ -299,10 +314,7 @@ service: `, stdout) require.Contains( t, stderr, - fmt.Sprintf(`Discovering for next 20s... -Successfully discovered "prometheus_simple" using "docker_observer" endpoint "%s:9090". -Discovery complete. -`, prometheus.GetContainerID()), + fmt.Sprintf(`Successfully discovered "prometheus_simple" using "docker_observer" endpoint "%s:9090".`, prometheus.GetContainerID()), ) require.Zero(t, sc) }