From c4e3cb7501656ff01468b879d1d127e071611fc3 Mon Sep 17 00:00:00 2001 From: Samiur Arif Date: Tue, 2 Jul 2024 15:19:50 -0700 Subject: [PATCH] addressing previour PR comments Signed-off-by: Samiur Arif --- CHANGELOG.md | 1 + .../receivers/rabbitmq.discovery.yaml | 32 +++++++++++++++++++ .../receivers/rabbitmq.discovery.yaml | 28 ++++++++++++++++ .../receivers/rabbitmq.discovery.yaml.tmpl | 24 ++++++++++++++ .../discovery/bundle/bundle_gen.go | 2 ++ .../discovery/bundle/bundledfs_other_test.go | 1 + .../discovery/bundle/bundledfs_others.go | 1 + .../discovery/bundle/bundledfs_windows.go | 1 + .../bundle/bundledfs_windows_test.go | 1 + .../discovery/bundle/components.go | 2 ++ 10 files changed, 93 insertions(+) create mode 100644 cmd/otelcol/config/collector/config.d.linux/receivers/rabbitmq.discovery.yaml create mode 100644 internal/confmapprovider/discovery/bundle/bundle.d/receivers/rabbitmq.discovery.yaml create mode 100644 internal/confmapprovider/discovery/bundle/bundle.d/receivers/rabbitmq.discovery.yaml.tmpl diff --git a/CHANGELOG.md b/CHANGELOG.md index ec0c65082f..815974ab7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - (Splunk) `discovery`: Enable discovery mode for SQL Server receiver ([#5109](https://github.com/signalfx/splunk-otel-collector/pull/5109)) - (Splunk) Update bundled OpenJDK to [11.0.24_8](https://github.com/adoptium/temurin11-binaries/releases/tag/jdk-11.0.24%2B8) ([#5113](https://github.com/signalfx/splunk-otel-collector/pull/5113)) +- (Splunk) Rabbitmq receiver was added into the discovery feature([#5113](https://github.com/signalfx/splunk-otel-collector/pull/5051)) ## v0.104.0 diff --git a/cmd/otelcol/config/collector/config.d.linux/receivers/rabbitmq.discovery.yaml b/cmd/otelcol/config/collector/config.d.linux/receivers/rabbitmq.discovery.yaml new file mode 100644 index 0000000000..6534650972 --- /dev/null +++ b/cmd/otelcol/config/collector/config.d.linux/receivers/rabbitmq.discovery.yaml @@ -0,0 +1,32 @@ +##################################################################################### +# 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. # +##################################################################################### +# rabbitmq: +# enabled: true +# rule: +# docker_observer: type == "container" and any([name, image, command], {# matches "(?i)rabbitmq.*"}) and not (command matches "splunk.discovery") +# host_observer: type == "hostport" and command matches "(?i)rabbitmq.*" and not (command matches "splunk.discovery") +# k8s_observer: type == "port" and pod.name matches "(?i)rabbitmq.*" +# config: +# default: +# endpoint: '`endpoint`' +# username: splunk.discovery.default +# password: splunk.discovery.default +# collection_interval: 10s +# status: +# metrics: +# - status: successful +# strict: rabbitmq.consumer.count +# message: RabbitMQ receiver is working! +# statements: +# - status: failed +# regexp: 'connect: network is unreachable' +# message: The endpoint is refusing RabbitMQ server connections. +# - status: failed +# regexp: 'connect: connection refused' +# message: The container is refusing RabbitMQ server connections. diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/rabbitmq.discovery.yaml b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/rabbitmq.discovery.yaml new file mode 100644 index 0000000000..73a511485d --- /dev/null +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/rabbitmq.discovery.yaml @@ -0,0 +1,28 @@ +##################################################################################### +# Do not edit manually! # +# All changes must be made to associated .tmpl file before running 'make bundle.d'. # +##################################################################################### +rabbitmq: + enabled: true + rule: + docker_observer: type == "container" and any([name, image, command], {# matches "(?i)rabbitmq.*"}) and not (command matches "splunk.discovery") + host_observer: type == "hostport" and command matches "(?i)rabbitmq.*" and not (command matches "splunk.discovery") + k8s_observer: type == "port" and pod.name matches "(?i)rabbitmq.*" + config: + default: + endpoint: '`endpoint`' + username: splunk.discovery.default + password: splunk.discovery.default + collection_interval: 10s + status: + metrics: + - status: successful + strict: rabbitmq.consumer.count + message: RabbitMQ receiver is working! + statements: + - status: failed + regexp: 'connect: network is unreachable' + message: The endpoint is refusing RabbitMQ server connections. + - status: failed + regexp: 'connect: connection refused' + message: The container is refusing RabbitMQ server connections. diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/rabbitmq.discovery.yaml.tmpl b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/rabbitmq.discovery.yaml.tmpl new file mode 100644 index 0000000000..61c02b14c0 --- /dev/null +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/rabbitmq.discovery.yaml.tmpl @@ -0,0 +1,24 @@ +{{ receiver "rabbitmq" }}: + enabled: true + rule: + docker_observer: type == "container" and any([name, image, command], {# matches "(?i)rabbitmq.*"}) and not (command matches "splunk.discovery") + host_observer: type == "hostport" and command matches "(?i)rabbitmq.*" and not (command matches "splunk.discovery") + k8s_observer: type == "port" and pod.name matches "(?i)rabbitmq.*" + config: + default: + endpoint: '`endpoint`' + username: {{ defaultValue }} + password: {{ defaultValue }} + collection_interval: 10s + status: + metrics: + - status: successful + strict: rabbitmq.consumer.count + message: RabbitMQ receiver is working! + statements: + - status: failed + regexp: 'connect: network is unreachable' + message: The endpoint is refusing RabbitMQ server connections. + - status: failed + regexp: 'connect: connection refused' + message: The endpoint is refusing RabbitMQ server connections. diff --git a/internal/confmapprovider/discovery/bundle/bundle_gen.go b/internal/confmapprovider/discovery/bundle/bundle_gen.go index 109851d72f..3869103a0e 100644 --- a/internal/confmapprovider/discovery/bundle/bundle_gen.go +++ b/internal/confmapprovider/discovery/bundle/bundle_gen.go @@ -35,6 +35,8 @@ //go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/oracledb.discovery.yaml.tmpl //go:generate discoverybundler -r -t bundle.d/receivers/postgresql.discovery.yaml.tmpl //go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/postgresql.discovery.yaml.tmpl +//go:generate discoverybundler -r -t bundle.d/receivers/rabbitmq.discovery.yaml.tmpl +//go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/rabbitmq.discovery.yaml.tmpl //go:generate discoverybundler -r -t bundle.d/receivers/redis.discovery.yaml.tmpl //go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/redis.discovery.yaml.tmpl //go:generate discoverybundler -r -t bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml.tmpl diff --git a/internal/confmapprovider/discovery/bundle/bundledfs_other_test.go b/internal/confmapprovider/discovery/bundle/bundledfs_other_test.go index 4727c0224a..c8b6349a3e 100644 --- a/internal/confmapprovider/discovery/bundle/bundledfs_other_test.go +++ b/internal/confmapprovider/discovery/bundle/bundledfs_other_test.go @@ -33,6 +33,7 @@ func TestBundleDir(t *testing.T) { "bundle.d/receivers/mysql.discovery.yaml", "bundle.d/receivers/oracledb.discovery.yaml", "bundle.d/receivers/postgresql.discovery.yaml", + "bundle.d/receivers/rabbitmq.discovery.yaml", "bundle.d/receivers/redis.discovery.yaml", "bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml", "bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml", diff --git a/internal/confmapprovider/discovery/bundle/bundledfs_others.go b/internal/confmapprovider/discovery/bundle/bundledfs_others.go index 2540a16e4e..5e413be1cc 100644 --- a/internal/confmapprovider/discovery/bundle/bundledfs_others.go +++ b/internal/confmapprovider/discovery/bundle/bundledfs_others.go @@ -31,6 +31,7 @@ import ( //go:embed bundle.d/receivers/mysql.discovery.yaml //go:embed bundle.d/receivers/oracledb.discovery.yaml //go:embed bundle.d/receivers/postgresql.discovery.yaml +//go:embed bundle.d/receivers/rabbitmq.discovery.yaml //go:embed bundle.d/receivers/redis.discovery.yaml //go:embed bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml //go:embed bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml diff --git a/internal/confmapprovider/discovery/bundle/bundledfs_windows.go b/internal/confmapprovider/discovery/bundle/bundledfs_windows.go index 1854171e43..55d68bb439 100644 --- a/internal/confmapprovider/discovery/bundle/bundledfs_windows.go +++ b/internal/confmapprovider/discovery/bundle/bundledfs_windows.go @@ -31,6 +31,7 @@ import ( //go:embed bundle.d/receivers/mysql.discovery.yaml //go:embed bundle.d/receivers/oracledb.discovery.yaml //go:embed bundle.d/receivers/postgresql.discovery.yaml +//go:embed bundle.d/receivers/rabbitmq.discovery.yaml //go:embed bundle.d/receivers/redis.discovery.yaml //go:embed bundle.d/receivers/smartagent-postgresql.discovery.yaml //go:embed bundle.d/receivers/sqlserver.discovery.yaml diff --git a/internal/confmapprovider/discovery/bundle/bundledfs_windows_test.go b/internal/confmapprovider/discovery/bundle/bundledfs_windows_test.go index c799856948..28bde529f2 100644 --- a/internal/confmapprovider/discovery/bundle/bundledfs_windows_test.go +++ b/internal/confmapprovider/discovery/bundle/bundledfs_windows_test.go @@ -33,6 +33,7 @@ func TestBundleDir(t *testing.T) { "bundle.d/receivers/mysql.discovery.yaml", "bundle.d/receivers/oracledb.discovery.yaml", "bundle.d/receivers/postgresql.discovery.yaml", + "bundle.d/receivers/rabbitmq.discovery.yaml", "bundle.d/receivers/redis.discovery.yaml", "bundle.d/receivers/smartagent-postgresql.discovery.yaml", "bundle.d/receivers/sqlserver.discovery.yaml", diff --git a/internal/confmapprovider/discovery/bundle/components.go b/internal/confmapprovider/discovery/bundle/components.go index 87db1ae62d..e4eb826150 100644 --- a/internal/confmapprovider/discovery/bundle/components.go +++ b/internal/confmapprovider/discovery/bundle/components.go @@ -37,6 +37,7 @@ var ( "mysql", "oracledb", "postgresql", + "rabbitmq", "redis", "smartagent-collectd-mysql", "smartagent-collectd-nginx", @@ -71,6 +72,7 @@ var ( "mysql": {}, "oracledb": {}, "postgresql": {}, + "rabbitmq": {}, "redis": {}, "smartagent-postgresql": {}, "sqlserver": {},