-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding mysqlreceiver dockerobserver test for discovery mode
- Loading branch information
Samiur Arif
committed
Jan 19, 2024
1 parent
d7ead56
commit 05dbd13
Showing
14 changed files
with
971 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
cmd/otelcol/config/collector/config.d.linux/receivers/mysql.discovery.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
##################################################################################### | ||
# This file is generated by the Splunk Distribution of the OpenTelemetry Collector. # | ||
# # | ||
# It reflects the default configuration bundled in the Collector executable for use # | ||
# in discovery mode (--discovery) and is provided for reference or customization. # | ||
# Please note that any changes made to this file will need to be reconciled during # | ||
# upgrades of the Collector. # | ||
##################################################################################### | ||
# mysql: | ||
# enabled: false | ||
# rule: | ||
# docker_observer: type == "container" and port != 33060 and any([name, image, command], {# matches "(?i)mysql"}) and not (command matches "splunk.discovery") | ||
# host_observer: type == "hostport" and port != 33060 and command matches "(?i)mysqld" | ||
# k8s_observer: type == "port" and port != 33060 and pod.name matches "(?i)mysql" | ||
# config: | ||
# default: | ||
# username: splunk.discovery.default | ||
# password: splunk.discovery.default | ||
# status: | ||
# metrics: | ||
# successful: | ||
# - strict: mysql.locks | ||
# first_only: true | ||
# log_record: | ||
# severity_text: info | ||
# body: Mysql receiver is working! | ||
# statements: | ||
# failed: | ||
# - regexp: "Can't connect to MySQL server on .* [(]111[)]" | ||
# first_only: true | ||
# log_record: | ||
# severity_text: info | ||
# append_pattern: true | ||
# body: The container cannot be reached by the Collector. The container is refusing MySQL connections. | ||
# partial: | ||
# - regexp: 'Access denied for user' | ||
# first_only: true | ||
# log_record: | ||
# severity_text: info | ||
# append_pattern: true | ||
# body: >- | ||
# Make sure your user credentials are correctly specified using the | ||
# `--set splunk.discovery.receivers.mysql.config.username="<username>"` and | ||
# `--set splunk.discovery.receivers.mysql.config.password="<password>"` command or the | ||
# `SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_username="<username>"` and | ||
# `SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_password="<password>"` environment variables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
internal/confmapprovider/discovery/bundle/bundle.d/receivers/mysql.discovery.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
##################################################################################### | ||
# Do not edit manually! # | ||
# All changes must be made to associated .tmpl file before running 'make bundle.d'. # | ||
##################################################################################### | ||
mysql: | ||
enabled: false | ||
rule: | ||
docker_observer: type == "container" and port != 33060 and any([name, image, command], {# matches "(?i)mysql"}) and not (command matches "splunk.discovery") | ||
host_observer: type == "hostport" and port != 33060 and command matches "(?i)mysqld" | ||
k8s_observer: type == "port" and port != 33060 and pod.name matches "(?i)mysql" | ||
config: | ||
default: | ||
username: splunk.discovery.default | ||
password: splunk.discovery.default | ||
status: | ||
metrics: | ||
successful: | ||
- strict: mysql.locks | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: Mysql receiver is working! | ||
statements: | ||
failed: | ||
- regexp: "Can't connect to MySQL server on .* [(]111[)]" | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
append_pattern: true | ||
body: The container cannot be reached by the Collector. The container is refusing MySQL connections. | ||
partial: | ||
- regexp: 'Access denied for user' | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
append_pattern: true | ||
body: >- | ||
Make sure your user credentials are correctly specified using the | ||
`--set splunk.discovery.receivers.mysql.config.username="<username>"` and | ||
`--set splunk.discovery.receivers.mysql.config.password="<password>"` command or the | ||
`SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_username="<username>"` and | ||
`SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_password="<password>"` environment variables. |
38 changes: 38 additions & 0 deletions
38
internal/confmapprovider/discovery/bundle/bundle.d/receivers/mysql.discovery.yaml.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{{ receiver "mysql" }}: | ||
enabled: false | ||
rule: | ||
docker_observer: type == "container" and port != 33060 and any([name, image, command], {# matches "(?i)mysql"}) and not (command matches "splunk.discovery") | ||
host_observer: type == "hostport" and port != 33060 and command matches "(?i)mysqld" | ||
k8s_observer: type == "port" and port != 33060 and pod.name matches "(?i)mysql" | ||
config: | ||
default: | ||
username: {{ defaultValue }} | ||
password: {{ defaultValue }} | ||
status: | ||
metrics: | ||
successful: | ||
- strict: mysql.locks | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: Mysql receiver is working! | ||
statements: | ||
failed: | ||
- regexp: "Can't connect to MySQL server on .* [(]111[)]" | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
append_pattern: true | ||
body: The container cannot be reached by the Collector. The container is refusing MySQL connections. | ||
partial: | ||
- regexp: 'Access denied for user' | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
append_pattern: true | ||
body: >- | ||
Make sure your user credentials are correctly specified using the | ||
`--set {{ configProperty "username" "<username>" }}` and | ||
`--set {{ configProperty "password" "<password>" }}` command or the | ||
`{{ configPropertyEnvVar "username" "<username>" }}` and | ||
`{{ configPropertyEnvVar "password" "<password>" }}` environment variables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright Splunk, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:build integration | ||
|
||
package tests | ||
|
||
import ( | ||
"fmt" | ||
"path" | ||
"runtime" | ||
"testing" | ||
|
||
"github.com/signalfx/splunk-otel-collector/tests/testutils" | ||
) | ||
|
||
func TestMysqlDockerObserver(t *testing.T) { | ||
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") | ||
} | ||
port := "3306" | ||
mysql := []testutils.Container{testutils.NewContainer().WithContext( | ||
path.Join(".", "testdata", "server"), | ||
).WithName("mysql").WithExposedPorts(port + ":" + port).WillWaitForPorts(port).WillWaitForLogs("")} | ||
testutils.SkipIfNotContainerTest(t) | ||
|
||
testutils.AssertAllMetricsReceived(t, "bundled.yaml", "otlp_exporter.yaml", | ||
mysql, []testutils.CollectorBuilder{ | ||
func(c testutils.Collector) testutils.Collector { | ||
cc := c.(*testutils.CollectorContainer) | ||
cc.Container = cc.Container.WithBinds("/var/run/docker.sock:/var/run/docker.sock:ro") | ||
cc.Container = cc.Container.WillWaitForLogs("Discovering for next") | ||
cc.Container = cc.Container.WithUser(fmt.Sprintf("999:%d", testutils.GetDockerGID(t))) | ||
return cc | ||
}, | ||
func(collector testutils.Collector) testutils.Collector { | ||
return collector.WithEnv(map[string]string{ | ||
"SPLUNK_DISCOVERY_DURATION": "10s", | ||
"SPLUNK_DISCOVERY_LOG_LEVEL": "debug", | ||
}).WithArgs( | ||
"--discovery", | ||
"--set", `splunk.discovery.extensions.k8s_observer.enabled=false`, | ||
"--set", `splunk.discovery.extensions.host_observer.enabled=false`, | ||
"--set", `splunk.discovery.receivers.mysql.config.username=root`, | ||
"--set", `splunk.discovery.receivers.mysql.config.password=testuser`, | ||
"--set", `splunk.discovery.receivers.mysql.enabled=true`, | ||
) | ||
}, | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
exporters: | ||
otlp: | ||
endpoint: "${OTLP_ENDPOINT}" | ||
tls: | ||
insecure: true | ||
|
||
service: | ||
telemetry: | ||
logs: | ||
level: debug | ||
pipelines: | ||
metrics: | ||
exporters: [otlp] |
Oops, something went wrong.