diff --git a/cmd/otelcol/config/collector/config.d.linux/receivers/oracledb.discovery.yaml b/cmd/otelcol/config/collector/config.d.linux/receivers/oracledb.discovery.yaml new file mode 100644 index 0000000000..8dec37f1e9 --- /dev/null +++ b/cmd/otelcol/config/collector/config.d.linux/receivers/oracledb.discovery.yaml @@ -0,0 +1,76 @@ +##################################################################################### +# 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. # +##################################################################################### +# oracledb: +# enabled: true +# rule: +# docker_observer: type == "container" and any([name, image, command], {# matches "(?i)oracle"}) and not (command matches "splunk.discovery") +# host_observer: type == "hostport" and command matches "(?i)oracle" and not (command matches "splunk.discovery") +# k8s_observer: type == "port" and pod.name matches "(?i)oracle" +# config: +# default: +# endpoint: splunk.discovery.default +# username: splunk.discovery.default +# password: splunk.discovery.default +# service: splunk.discovery.default +# status: +# metrics: +# successful: +# - strict: oracledb.cpu_time +# first_only: true +# log_record: +# severity_text: info +# body: oracledb receiver is working! +# statements: +# failed: +# - regexp: "connection refused" +# first_only: true +# log_record: +# severity_text: info +# append_pattern: true +# body: The container is not serving http connections. +# - regexp: "received goaway and there are no active streams" +# first_only: true +# log_record: +# severity_text: info +# append_pattern: true +# body: Unable to connect and scrape metrics. +# - regexp: "dial tcp: lookup" +# first_only: true +# log_record: +# severity_text: info +# append_pattern: true +# body: Unable to resolve oracledb tcp endpoint +# - regexp: 'error executing select .*: EOF' +# first_only: true +# log_record: +# severity_text: info +# append_pattern: true +# body: Unable to execute select from oracledb. Verify endpoint and user permissions. +# partial: +# - regexp: "listener does not currently know of service requested" +# first_only: true +# log_record: +# severity_text: info +# append_pattern: true +# body: >- +# Make sure your oracledb service is correctly specified using the +# `--set splunk.discovery.receivers.oracledb.config.service=""` command or the +# `SPLUNK_DISCOVERY_RECEIVERS_oracledb_CONFIG_service=""` environment variable. +# - regexp: 'invalid username/password' +# 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.oracledb.config.username=""` and +# `--set splunk.discovery.receivers.oracledb.config.password=""` command or the +# `SPLUNK_DISCOVERY_RECEIVERS_oracledb_CONFIG_username=""` and +# `SPLUNK_DISCOVERY_RECEIVERS_oracledb_CONFIG_password=""` environment variables. +# \ No newline at end of file diff --git a/internal/confmapprovider/discovery/README.md b/internal/confmapprovider/discovery/README.md index b67b7c1beb..e879836194 100644 --- a/internal/confmapprovider/discovery/README.md +++ b/internal/confmapprovider/discovery/README.md @@ -135,10 +135,11 @@ By default, the discovery mode is provided with pre-made discovery config compon The following components have bundled discovery configurations in the last Splunk OpenTelemetry Collector release: -I. Smart Agent receiver -* `collectd/mysql` monitor type ([Linux](./bundle/bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml)) -* `collectd/nginx` monitor type ([Linux](./bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml)) -* `postgresql` monitor type ([Linux and Windows](./bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml)) +I. Receivers +* `oracledb` ([Linux and Windows](./bundle/bundle.d/receivers/oracledb.discovery.yaml)) +* `smartagent` with `collectd/mysql` monitor type ([Linux](./bundle/bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml)) +* `smartagent` with `collectd/nginx` monitor type ([Linux](./bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml)) +* `smartagent` with `postgresql` monitor type ([Linux and Windows](./bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml)) II. Extensions * `docker_observer` ([Linux and Windows](./bundle/bundle.d/extensions/docker-observer.discovery.yaml)) diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml new file mode 100644 index 0000000000..b76e27ff01 --- /dev/null +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml @@ -0,0 +1,72 @@ +##################################################################################### +# Do not edit manually! # +# All changes must be made to associated .tmpl file before running 'make bundle.d'. # +##################################################################################### +oracledb: + enabled: true + rule: + docker_observer: type == "container" and any([name, image, command], {# matches "(?i)oracle"}) and not (command matches "splunk.discovery") + host_observer: type == "hostport" and command matches "(?i)oracle" and not (command matches "splunk.discovery") + k8s_observer: type == "port" and pod.name matches "(?i)oracle" + config: + default: + endpoint: splunk.discovery.default + username: splunk.discovery.default + password: splunk.discovery.default + service: splunk.discovery.default + status: + metrics: + successful: + - strict: oracledb.cpu_time + first_only: true + log_record: + severity_text: info + body: oracledb receiver is working! + statements: + failed: + - regexp: "connection refused" + first_only: true + log_record: + severity_text: info + append_pattern: true + body: The container is not serving http connections. + - regexp: "received goaway and there are no active streams" + first_only: true + log_record: + severity_text: info + append_pattern: true + body: Unable to connect and scrape metrics. + - regexp: "dial tcp: lookup" + first_only: true + log_record: + severity_text: info + append_pattern: true + body: Unable to resolve oracledb tcp endpoint + - regexp: 'error executing select .*: EOF' + first_only: true + log_record: + severity_text: info + append_pattern: true + body: Unable to execute select from oracledb. Verify endpoint and user permissions. + partial: + - regexp: "listener does not currently know of service requested" + first_only: true + log_record: + severity_text: info + append_pattern: true + body: >- + Make sure your oracledb service is correctly specified using the + `--set splunk.discovery.receivers.oracledb.config.service=""` command or the + `SPLUNK_DISCOVERY_RECEIVERS_oracledb_CONFIG_service=""` environment variable. + - regexp: 'invalid username/password' + 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.oracledb.config.username=""` and + `--set splunk.discovery.receivers.oracledb.config.password=""` command or the + `SPLUNK_DISCOVERY_RECEIVERS_oracledb_CONFIG_username=""` and + `SPLUNK_DISCOVERY_RECEIVERS_oracledb_CONFIG_password=""` environment variables. + \ No newline at end of file diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml.tmpl b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml.tmpl new file mode 100644 index 0000000000..4b441ecb1d --- /dev/null +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml.tmpl @@ -0,0 +1,68 @@ +{{ receiver "oracledb" }}: + enabled: true + rule: + docker_observer: type == "container" and any([name, image, command], {# matches "(?i)oracle"}) and not (command matches "splunk.discovery") + host_observer: type == "hostport" and command matches "(?i)oracle" and not (command matches "splunk.discovery") + k8s_observer: type == "port" and pod.name matches "(?i)oracle" + config: + default: + endpoint: {{ defaultValue }} + username: {{ defaultValue }} + password: {{ defaultValue }} + service: {{ defaultValue }} + status: + metrics: + successful: + - strict: oracledb.cpu_time + first_only: true + log_record: + severity_text: info + body: oracledb receiver is working! + statements: + failed: + - regexp: "connection refused" + first_only: true + log_record: + severity_text: info + append_pattern: true + body: The container is not serving http connections. + - regexp: "received goaway and there are no active streams" + first_only: true + log_record: + severity_text: info + append_pattern: true + body: Unable to connect and scrape metrics. + - regexp: "dial tcp: lookup" + first_only: true + log_record: + severity_text: info + append_pattern: true + body: Unable to resolve oracledb tcp endpoint + - regexp: 'error executing select .*: EOF' + first_only: true + log_record: + severity_text: info + append_pattern: true + body: Unable to execute select from oracledb. Verify endpoint and user permissions. + partial: + - regexp: "listener does not currently know of service requested" + first_only: true + log_record: + severity_text: info + append_pattern: true + body: >- + Make sure your oracledb service is correctly specified using the + `--set {{ configProperty "service" "" }}` command or the + `{{ configPropertyEnvVar "service" "" }}` environment variable. + - regexp: 'invalid username/password' + 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" "" }}` and + `--set {{ configProperty "password" "" }}` command or the + `{{ configPropertyEnvVar "username" "" }}` and + `{{ configPropertyEnvVar "password" "" }}` environment variables. + \ 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 5748baa7e6..71251eb0e3 100644 --- a/internal/confmapprovider/discovery/bundle/bundle_gen.go +++ b/internal/confmapprovider/discovery/bundle/bundle_gen.go @@ -25,6 +25,8 @@ //go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml.tmpl //go:generate discoverybundler -r -t bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml.tmpl //go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml.tmpl +//go:generate discoverybundler -r -t bundle.d/receivers/oracledb.discovery.yaml.tmpl +//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/extensions/docker-observer.discovery.yaml.tmpl //go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/extensions -t bundle.d/extensions/docker-observer.discovery.yaml.tmpl diff --git a/internal/confmapprovider/discovery/bundle/bundle_other_test.go b/internal/confmapprovider/discovery/bundle/bundle_other_test.go index 6ea3b2385f..b1c4b01118 100644 --- a/internal/confmapprovider/discovery/bundle/bundle_other_test.go +++ b/internal/confmapprovider/discovery/bundle/bundle_other_test.go @@ -27,6 +27,7 @@ func TestBundleDir(t *testing.T) { receivers, err := fs.Glob(BundledFS, "bundle.d/receivers/*.discovery.yaml") require.NoError(t, err) require.Equal(t, []string{ + "bundle.d/receivers/oracledb.discovery.yaml", "bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml", "bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml", "bundle.d/receivers/smartagent-postgresql.discovery.yaml", diff --git a/internal/confmapprovider/discovery/bundle/bundle_windows.go b/internal/confmapprovider/discovery/bundle/bundle_windows.go index cf195ac45a..00350e8aa7 100644 --- a/internal/confmapprovider/discovery/bundle/bundle_windows.go +++ b/internal/confmapprovider/discovery/bundle/bundle_windows.go @@ -27,5 +27,6 @@ import ( // build errors. // //go:embed bundle.d/extensions/*.discovery.yaml +//go:embed bundle.d/receivers/oracledb.discovery.yaml //go:embed bundle.d/receivers/smartagent-postgresql.discovery.yaml var BundledFS embed.FS diff --git a/internal/confmapprovider/discovery/bundle/bundle_windows_test.go b/internal/confmapprovider/discovery/bundle/bundle_windows_test.go index 13a00328ad..1a0b10f090 100644 --- a/internal/confmapprovider/discovery/bundle/bundle_windows_test.go +++ b/internal/confmapprovider/discovery/bundle/bundle_windows_test.go @@ -27,6 +27,7 @@ func TestBundleDir(t *testing.T) { receivers, err := fs.Glob(BundledFS, "bundle.d/receivers/*.discovery.yaml") require.NoError(t, err) require.Equal(t, []string{ + "bundle.d/receivers/oracledb.discovery.yaml", "bundle.d/receivers/smartagent-postgresql.discovery.yaml", }, receivers) diff --git a/tests/receivers/oracledb/bundled_test.go b/tests/receivers/oracledb/bundled_test.go new file mode 100644 index 0000000000..a853789d71 --- /dev/null +++ b/tests/receivers/oracledb/bundled_test.go @@ -0,0 +1,61 @@ +// 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" + "runtime" + "testing" + + "github.com/signalfx/splunk-otel-collector/tests/testutils" +) + +func TestOracledbDockerObserver(t *testing.T) { + testutils.SkipIfNotContainerTest(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") + } + + testutils.AssertAllMetricsReceived(t, "bundled.yaml", "otlp_exporter.yaml", + oracledb, []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{ + "ORACLEDB_URL": "oracle://otel:password@localhost:1521/XE", + "SPLUNK_DISCOVERY_DURATION": "10s", + // confirm that debug logging doesn't affect runtime + "SPLUNK_DISCOVERY_LOG_LEVEL": "debug", + "ORACLE_PASSWORD": "password", + }).WithArgs( + "--discovery", + "--set", "splunk.discovery.receivers.oracledb.config.username=otel", + "--set", "splunk.discovery.receivers.oracledb.config.password='${ORACLE_PASSWORD}'", + "--set", "splunk.discovery.receivers.oracledb.config.endpoint=localhost:1521", + "--set", "splunk.discovery.receivers.oracledb.config.service=XE", + "--set", `splunk.discovery.extensions.k8s_observer.enabled=false`, + "--set", `splunk.discovery.extensions.host_observer.enabled=false`, + ) + }, + }, + ) +} diff --git a/tests/receivers/oracledb/oracledb_test.go b/tests/receivers/oracledb/oracledb_test.go index c43727b95f..2774013f55 100644 --- a/tests/receivers/oracledb/oracledb_test.go +++ b/tests/receivers/oracledb/oracledb_test.go @@ -29,7 +29,7 @@ import ( // account for startup time is to wait for the container to be healthy before continuing test. var oracledb = []testutils.Container{testutils.NewContainer().WithContext( path.Join(".", "testdata", "server"), -).WithName("oracledb").WithExposedPorts("1521:1521").WillWaitForHealth(15 * time.Minute)} +).WithName("oracledb").WithExposedPorts("1521:1521").WillWaitForHealth(5 * time.Minute)} // This test ensures the collector can connect to an Oracle DB, and properly get metrics. It's not intended to // test the receiver itself. diff --git a/tests/receivers/oracledb/testdata/otlp_exporter.yaml b/tests/receivers/oracledb/testdata/otlp_exporter.yaml new file mode 100644 index 0000000000..fa00f3c646 --- /dev/null +++ b/tests/receivers/oracledb/testdata/otlp_exporter.yaml @@ -0,0 +1,13 @@ +exporters: + otlp: + endpoint: "${OTLP_ENDPOINT}" + tls: + insecure: true + +service: + telemetry: + logs: + level: debug + pipelines: + metrics: + exporters: [otlp] diff --git a/tests/receivers/oracledb/testdata/resource_metrics/all.yaml b/tests/receivers/oracledb/testdata/resource_metrics/all.yaml index b964878a83..1b24c5b82f 100644 --- a/tests/receivers/oracledb/testdata/resource_metrics/all.yaml +++ b/tests/receivers/oracledb/testdata/resource_metrics/all.yaml @@ -3,6 +3,7 @@ resource_metrics: oracledb.instance.name: localhost:1521/XE scope_metrics: - instrumentation_scope: + attributes: {} name: otelcol/oracledbreceiver version: metrics: diff --git a/tests/receivers/oracledb/testdata/resource_metrics/bundled.yaml b/tests/receivers/oracledb/testdata/resource_metrics/bundled.yaml new file mode 100644 index 0000000000..5138d627a8 --- /dev/null +++ b/tests/receivers/oracledb/testdata/resource_metrics/bundled.yaml @@ -0,0 +1,63 @@ +resource_metrics: + - attributes: + container.image.name: + container.name: oracledb + oracledb.instance.name: localhost:1521/XE + scope_metrics: + - instrumentation_scope: + attributes: {} + name: otelcol/oracledbreceiver + version: + metrics: + - name: oracledb.cpu_time + type: DoubleMonotonicCumulativeSum + - name: oracledb.enqueue_deadlocks + type: IntMonotonicCumulativeSum + - name: oracledb.exchange_deadlocks + type: IntMonotonicCumulativeSum + - name: oracledb.executions + type: IntMonotonicCumulativeSum + - name: oracledb.hard_parses + type: IntMonotonicCumulativeSum + - name: oracledb.logical_reads + type: IntMonotonicCumulativeSum + - name: oracledb.parse_calls + type: IntMonotonicCumulativeSum + - name: oracledb.pga_memory + type: IntMonotonicCumulativeSum + - name: oracledb.physical_reads + type: IntMonotonicCumulativeSum + - name: oracledb.user_commits + type: IntMonotonicCumulativeSum + - name: oracledb.user_rollbacks + type: IntMonotonicCumulativeSum + - name: oracledb.sessions.usage + type: IntGauge + - name: oracledb.processes.usage + type: IntGauge + - name: oracledb.processes.limit + type: IntGauge + - name: oracledb.sessions.usage + type: IntGauge + - name: oracledb.sessions.limit + type: IntGauge + - name: oracledb.enqueue_locks.usage + type: IntGauge + - name: oracledb.enqueue_locks.limit + type: IntGauge + - name: oracledb.enqueue_resources.usage + type: IntGauge + - name: oracledb.enqueue_resources.limit + type: IntGauge + - name: oracledb.transactions.usage + type: IntGauge + - name: oracledb.transactions.limit + type: IntGauge + - name: oracledb.dml_locks.usage + type: IntGauge + - name: oracledb.dml_locks.limit + type: IntGauge + - name: oracledb.tablespace_size.limit + type: IntGauge + - name: oracledb.tablespace_size.usage + type: IntGauge \ No newline at end of file