From 74425b82ce90f6c9a77fdad82c7311fbe5318228 Mon Sep 17 00:00:00 2001 From: Samiur Arif Date: Tue, 2 Jul 2024 15:19:50 -0700 Subject: [PATCH] added rabbitmq to the auto discovery mechanism --- .../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 ++ 9 files changed, 92 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/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..844a6c524e --- /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: http://localhost:15672 +# 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 container cannot be reached by the Collector. Make sure they're in the same network. +# - status: failed +# regexp: 'connect: connection refused' +# message: The container is refusing kafka server connections. \ No newline at end of file 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..47727f668a --- /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: http://localhost:15672 + 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 container cannot be reached by the Collector. Make sure they're in the same network. + - status: failed + regexp: 'connect: connection refused' + message: The container is refusing kafka server connections. \ No newline at end of file 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..8c27a7a6ff --- /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: http://localhost:15672 + 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 container cannot be reached by the Collector. Make sure they're in the same network. + - status: failed + regexp: 'connect: connection refused' + message: The container is refusing kafka server connections. \ No newline at end of file diff --git a/internal/confmapprovider/discovery/bundle/bundle_gen.go b/internal/confmapprovider/discovery/bundle/bundle_gen.go index 05edf3365f..04b585bcb3 100644 --- a/internal/confmapprovider/discovery/bundle/bundle_gen.go +++ b/internal/confmapprovider/discovery/bundle/bundle_gen.go @@ -33,6 +33,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 ee70bf5191..aadd42eacd 100644 --- a/internal/confmapprovider/discovery/bundle/bundledfs_other_test.go +++ b/internal/confmapprovider/discovery/bundle/bundledfs_other_test.go @@ -32,6 +32,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 d06a236825..51e34cdd45 100644 --- a/internal/confmapprovider/discovery/bundle/bundledfs_others.go +++ b/internal/confmapprovider/discovery/bundle/bundledfs_others.go @@ -30,6 +30,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 48da255e77..1ee0afd443 100644 --- a/internal/confmapprovider/discovery/bundle/bundledfs_windows.go +++ b/internal/confmapprovider/discovery/bundle/bundledfs_windows.go @@ -30,6 +30,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 var BundledFS embed.FS diff --git a/internal/confmapprovider/discovery/bundle/bundledfs_windows_test.go b/internal/confmapprovider/discovery/bundle/bundledfs_windows_test.go index cf7036c7ef..8c140df885 100644 --- a/internal/confmapprovider/discovery/bundle/bundledfs_windows_test.go +++ b/internal/confmapprovider/discovery/bundle/bundledfs_windows_test.go @@ -32,6 +32,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", }, receivers) diff --git a/internal/confmapprovider/discovery/bundle/components.go b/internal/confmapprovider/discovery/bundle/components.go index b59e0e701d..8bf123980d 100644 --- a/internal/confmapprovider/discovery/bundle/components.go +++ b/internal/confmapprovider/discovery/bundle/components.go @@ -36,6 +36,7 @@ var ( "mysql", "oracledb", "postgresql", + "rabbitmq", "redis", "smartagent-collectd-mysql", "smartagent-collectd-nginx", @@ -68,6 +69,7 @@ var ( "mysql": {}, "oracledb": {}, "postgresql": {}, + "rabbitmq": {}, "redis": {}, "smartagent-postgresql": {}, }