Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docker observer #4516

Merged
merged 2 commits into from Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 16 additions & 4 deletions tests/general/discoverymode/docker_observer_discovery_test.go
Expand Up @@ -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"},
},
Expand Down Expand Up @@ -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"},
},
Expand Down Expand Up @@ -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:
Expand All @@ -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)
}
1 change: 1 addition & 0 deletions tests/receivers/mysql/bundled_test.go
Expand Up @@ -26,6 +26,7 @@ import (
)

func TestMysqlDockerObserver(t *testing.T) {
t.Skip("Redis data points are also discovered since Redis runs, making this test fail.")
if runtime.GOOS == "darwin" {
t.Skip("unable to share sockets between mac and d4m vm: https://github.com/docker/for-mac/issues/483#issuecomment-758836836")
}
Expand Down