diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a9ffec853..d65795d725 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### 🛑 Breaking changes 🛑 + +- (Splunk) `receiver/discovery`: Remove `severity_text` field from log evaluation statements. ([#4583](https://github.com/signalfx/splunk-otel-collector/pull/4583)) + ## v0.97.0 ### 🚀 New components 🚀 diff --git a/cmd/otelcol/config/collector/config.d.linux/receivers/mysql.discovery.yaml b/cmd/otelcol/config/collector/config.d.linux/receivers/mysql.discovery.yaml index bf26037b20..8d6700a8f2 100644 --- a/cmd/otelcol/config/collector/config.d.linux/receivers/mysql.discovery.yaml +++ b/cmd/otelcol/config/collector/config.d.linux/receivers/mysql.discovery.yaml @@ -22,21 +22,18 @@ # - 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 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 index 4f1e787afb..faa4dd5ab0 100644 --- a/cmd/otelcol/config/collector/config.d.linux/receivers/oracledb.discovery.yaml +++ b/cmd/otelcol/config/collector/config.d.linux/receivers/oracledb.discovery.yaml @@ -23,39 +23,33 @@ # - 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 @@ -64,7 +58,6 @@ # - 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 diff --git a/cmd/otelcol/config/collector/config.d.linux/receivers/postgresql.discovery.yaml b/cmd/otelcol/config/collector/config.d.linux/receivers/postgresql.discovery.yaml index c3e6559338..88b5184469 100644 --- a/cmd/otelcol/config/collector/config.d.linux/receivers/postgresql.discovery.yaml +++ b/cmd/otelcol/config/collector/config.d.linux/receivers/postgresql.discovery.yaml @@ -22,27 +22,23 @@ # - strict: postgresql.commits # first_only: true # log_record: -# severity_text: info # body: PostgreSQL receiver is working! # statements: # failed: # - regexp: 'connect: network is unreachable' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: The container cannot be reached by the Collector. Make sure they're in the same network. # - regexp: 'connect: connection refused' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: The container is refusing PostgreSQL connections. # partial: # - regexp: 'pq: password authentication failed for user' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Please ensure your user credentials are correctly specified with @@ -53,7 +49,6 @@ # - regexp: 'pq: database .* does not exist' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Make sure the target database is correctly specified using the @@ -62,7 +57,6 @@ # - regexp: 'pq: SSL is not enabled on the server' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Make sure the target database has SSL enabled or set insecure using the @@ -71,7 +65,6 @@ # - regexp: 'pq: pg_stat_statements must be loaded via shared_preload_libraries' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Make sure your PostgreSQL database has diff --git a/cmd/otelcol/config/collector/config.d.linux/receivers/redis.discovery.yaml b/cmd/otelcol/config/collector/config.d.linux/receivers/redis.discovery.yaml index b7a02e535d..746222a4aa 100644 --- a/cmd/otelcol/config/collector/config.d.linux/receivers/redis.discovery.yaml +++ b/cmd/otelcol/config/collector/config.d.linux/receivers/redis.discovery.yaml @@ -20,33 +20,28 @@ # - strict: redis.uptime # first_only: true # log_record: -# severity_text: info # body: redis 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 redis tcp endpoint # partial: # - regexp: 'NOAUTH Authentication required.' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Make sure your user credentials are correctly specified using the @@ -57,7 +52,6 @@ # - regexp: 'called without any password configured for the default user' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Make sure your user credentials are correctly specified using the @@ -66,7 +60,6 @@ # - regexp: 'WRONGPASS invalid username-password pair or user is disabled' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Make sure your user credentials are correctly specified using the diff --git a/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-collectd-mysql.discovery.yaml b/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-collectd-mysql.discovery.yaml index 979af232c8..00853a51d1 100644 --- a/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-collectd-mysql.discovery.yaml +++ b/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-collectd-mysql.discovery.yaml @@ -26,21 +26,18 @@ # - strict: mysql_octets.rx # first_only: true # log_record: -# severity_text: info # body: smartagent/collectd/mysql receiver is working! # statements: # failed: # - regexp: "mysql plugin: Failed to connect to database .* at server .* Can't connect to MySQL server on .* [(]111[)]" # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: The container is refusing MySQL connections. # partial: # - regexp: 'mysql plugin: Failed to connect to database .* at server .* Access denied for user .* [(]using password: .*[)]' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Make sure your user credentials are correctly specified using the @@ -51,7 +48,6 @@ # - regexp: 'mysql plugin: Failed to connect to database .* at server .* Unknown database' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Make sure your MySQL databases are correctly specified using the @@ -60,7 +56,6 @@ # - regexp: 'mysql plugin: Failed to connect to database .* at server .* Access denied for user .* to database' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Make sure your MySQL databases and auth information are correctly specified using the diff --git a/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-collectd-nginx.discovery.yaml b/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-collectd-nginx.discovery.yaml index c5962d3965..46d29707c3 100644 --- a/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-collectd-nginx.discovery.yaml +++ b/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-collectd-nginx.discovery.yaml @@ -24,19 +24,16 @@ # - strict: connections.accepted # first_only: true # log_record: -# severity_text: info # body: smartagent/collectd/nginx receiver is working! # statements: # failed: # - regexp: "nginx plugin: curl_easy_perform failed: Operation timed out after" # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: The container is not serving http connections. # - regexp: "read-function of plugin .* failed" # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: The integration is unable to read metrics from this endpoint. \ No newline at end of file diff --git a/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-postgresql.discovery.yaml b/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-postgresql.discovery.yaml index 40ee4a400c..2e562dea83 100644 --- a/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-postgresql.discovery.yaml +++ b/cmd/otelcol/config/collector/config.d.linux/receivers/smartagent-postgresql.discovery.yaml @@ -26,13 +26,11 @@ # - strict: postgres_query_count # first_only: true # log_record: -# severity_text: info # body: PostgreSQL receiver is working! # partial: # - strict: postgres_rows_inserted # first_only: true # log_record: -# severity_text: info # body: >- # Make sure that # `CREATE EXTENSION IF NOT EXISTS pg_stat_statements;` @@ -44,20 +42,17 @@ # - regexp: 'connect: network is unreachable' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: The container cannot be reached by the Collector. Make sure they're in the same network. # - regexp: 'connect: connection refused' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: The container is refusing PostgreSQL connections. # partial: # - regexp: 'pq: password authentication failed for user' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Please ensure your user credentials are correctly specified with @@ -68,7 +63,6 @@ # - regexp: 'pq: database .* does not exist' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Make sure the target database is correctly specified using the @@ -77,7 +71,6 @@ # - regexp: 'pq: pg_stat_statements must be loaded via shared_preload_libraries' # first_only: true # log_record: -# severity_text: info # append_pattern: true # body: >- # Make sure your PostgreSQL database has diff --git a/internal/confmapprovider/discovery/bundle/README.md b/internal/confmapprovider/discovery/bundle/README.md index aebc568f38..705a485464 100644 --- a/internal/confmapprovider/discovery/bundle/README.md +++ b/internal/confmapprovider/discovery/bundle/README.md @@ -31,7 +31,6 @@ Example `redis.discovery.yaml.tmpl`: - regexp: 'ERR AUTH.*' first_only: true log_record: - severity_text: info body: >- Please ensure your redis password is correctly specified with `--set {{ configProperty "password" "" }}` or @@ -57,7 +56,6 @@ redis: - regexp: 'ERR AUTH.*' first_only: true log_record: - severity_text: info body: >- Please ensure your redis password is correctly specified with `--set splunk.discovery.receivers.redis.config.password=""` or diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/mysql.discovery.yaml b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/mysql.discovery.yaml index bd69f52df2..ae46b4c179 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/mysql.discovery.yaml +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/mysql.discovery.yaml @@ -18,21 +18,18 @@ mysql: - 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 diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/mysql.discovery.yaml.tmpl b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/mysql.discovery.yaml.tmpl index df611aa4ad..8d89cfbe89 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/mysql.discovery.yaml.tmpl +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/mysql.discovery.yaml.tmpl @@ -14,21 +14,18 @@ - 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 diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml index 0d348dfe45..b691af1339 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml @@ -19,39 +19,33 @@ oracledb: - 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 @@ -60,7 +54,6 @@ oracledb: - 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 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 index 7606be4737..ab0d61ebe8 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml.tmpl +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/oracledb.discovery.yaml.tmpl @@ -15,39 +15,33 @@ - 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 @@ -56,7 +50,6 @@ - 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 diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/postgresql.discovery.yaml b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/postgresql.discovery.yaml index cc4446be29..afc30c4cb0 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/postgresql.discovery.yaml +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/postgresql.discovery.yaml @@ -18,27 +18,23 @@ postgresql: - strict: postgresql.commits first_only: true log_record: - severity_text: info body: PostgreSQL receiver is working! statements: failed: - regexp: 'connect: network is unreachable' first_only: true log_record: - severity_text: info append_pattern: true body: The container cannot be reached by the Collector. Make sure they're in the same network. - regexp: 'connect: connection refused' first_only: true log_record: - severity_text: info append_pattern: true body: The container is refusing PostgreSQL connections. partial: - regexp: 'pq: password authentication failed for user' first_only: true log_record: - severity_text: info append_pattern: true body: >- Please ensure your user credentials are correctly specified with @@ -49,7 +45,6 @@ postgresql: - regexp: 'pq: database .* does not exist' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure the target database is correctly specified using the @@ -58,7 +53,6 @@ postgresql: - regexp: 'pq: SSL is not enabled on the server' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure the target database has SSL enabled or set insecure using the @@ -67,7 +61,6 @@ postgresql: - regexp: 'pq: pg_stat_statements must be loaded via shared_preload_libraries' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your PostgreSQL database has diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/postgresql.discovery.yaml.tmpl b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/postgresql.discovery.yaml.tmpl index d2d2a6f583..8eff38d888 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/postgresql.discovery.yaml.tmpl +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/postgresql.discovery.yaml.tmpl @@ -14,27 +14,23 @@ - strict: postgresql.commits first_only: true log_record: - severity_text: info body: PostgreSQL receiver is working! statements: failed: - regexp: 'connect: network is unreachable' first_only: true log_record: - severity_text: info append_pattern: true body: The container cannot be reached by the Collector. Make sure they're in the same network. - regexp: 'connect: connection refused' first_only: true log_record: - severity_text: info append_pattern: true body: The container is refusing PostgreSQL connections. partial: - regexp: 'pq: password authentication failed for user' first_only: true log_record: - severity_text: info append_pattern: true body: >- Please ensure your user credentials are correctly specified with @@ -45,7 +41,6 @@ - regexp: 'pq: database .* does not exist' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure the target database is correctly specified using the @@ -54,7 +49,6 @@ - regexp: 'pq: SSL is not enabled on the server' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure the target database has SSL enabled or set insecure using the @@ -63,7 +57,6 @@ - regexp: 'pq: pg_stat_statements must be loaded via shared_preload_libraries' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your PostgreSQL database has diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/redis.discovery.yaml b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/redis.discovery.yaml index cfd66a47dd..048d4c68ac 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/redis.discovery.yaml +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/redis.discovery.yaml @@ -16,33 +16,28 @@ redis: - strict: redis.uptime first_only: true log_record: - severity_text: info body: redis 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 redis tcp endpoint partial: - regexp: 'NOAUTH Authentication required.' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your user credentials are correctly specified using the @@ -53,7 +48,6 @@ redis: - regexp: 'called without any password configured for the default user' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your user credentials are correctly specified using the @@ -62,7 +56,6 @@ redis: - regexp: 'WRONGPASS invalid username-password pair or user is disabled' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your user credentials are correctly specified using the diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/redis.discovery.yaml.tmpl b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/redis.discovery.yaml.tmpl index a4b44874bd..ccc5fb2c08 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/redis.discovery.yaml.tmpl +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/redis.discovery.yaml.tmpl @@ -12,33 +12,28 @@ - strict: redis.uptime first_only: true log_record: - severity_text: info body: redis 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 redis tcp endpoint partial: - regexp: 'NOAUTH Authentication required.' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your user credentials are correctly specified using the @@ -49,7 +44,6 @@ - regexp: 'called without any password configured for the default user' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your user credentials are correctly specified using the @@ -58,7 +52,6 @@ - regexp: 'WRONGPASS invalid username-password pair or user is disabled' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your user credentials are correctly specified using the diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml index 2465b77e84..07afe0a611 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml @@ -22,21 +22,18 @@ smartagent/collectd/mysql: - strict: mysql_octets.rx first_only: true log_record: - severity_text: info body: smartagent/collectd/mysql receiver is working! statements: failed: - regexp: "mysql plugin: Failed to connect to database .* at server .* Can't connect to MySQL server on .* [(]111[)]" first_only: true log_record: - severity_text: info append_pattern: true body: The container is refusing MySQL connections. partial: - regexp: 'mysql plugin: Failed to connect to database .* at server .* Access denied for user .* [(]using password: .*[)]' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your user credentials are correctly specified using the @@ -47,7 +44,6 @@ smartagent/collectd/mysql: - regexp: 'mysql plugin: Failed to connect to database .* at server .* Unknown database' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your MySQL databases are correctly specified using the @@ -56,7 +52,6 @@ smartagent/collectd/mysql: - regexp: 'mysql plugin: Failed to connect to database .* at server .* Access denied for user .* to database' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your MySQL databases and auth information are correctly specified using the diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml.tmpl b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml.tmpl index 00261ee5cf..8bab5dc704 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml.tmpl +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml.tmpl @@ -18,21 +18,18 @@ - strict: mysql_octets.rx first_only: true log_record: - severity_text: info body: smartagent/collectd/mysql receiver is working! statements: failed: - regexp: "mysql plugin: Failed to connect to database .* at server .* Can't connect to MySQL server on .* [(]111[)]" first_only: true log_record: - severity_text: info append_pattern: true body: The container is refusing MySQL connections. partial: - regexp: 'mysql plugin: Failed to connect to database .* at server .* Access denied for user .* [(]using password: .*[)]' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your user credentials are correctly specified using the @@ -43,7 +40,6 @@ - regexp: 'mysql plugin: Failed to connect to database .* at server .* Unknown database' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your MySQL databases are correctly specified using the @@ -52,7 +48,6 @@ - regexp: 'mysql plugin: Failed to connect to database .* at server .* Access denied for user .* to database' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your MySQL databases and auth information are correctly specified using the diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml index 98890b36b2..7ddd4ab613 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml @@ -20,19 +20,16 @@ smartagent/collectd/nginx: - strict: connections.accepted first_only: true log_record: - severity_text: info body: smartagent/collectd/nginx receiver is working! statements: failed: - regexp: "nginx plugin: curl_easy_perform failed: Operation timed out after" first_only: true log_record: - severity_text: info append_pattern: true body: The container is not serving http connections. - regexp: "read-function of plugin .* failed" first_only: true log_record: - severity_text: info append_pattern: true body: The integration is unable to read metrics from this endpoint. \ No newline at end of file diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml.tmpl b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml.tmpl index cb39626cae..6e7bb8656c 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml.tmpl +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml.tmpl @@ -16,19 +16,16 @@ - strict: connections.accepted first_only: true log_record: - severity_text: info body: smartagent/collectd/nginx receiver is working! statements: failed: - regexp: "nginx plugin: curl_easy_perform failed: Operation timed out after" first_only: true log_record: - severity_text: info append_pattern: true body: The container is not serving http connections. - regexp: "read-function of plugin .* failed" first_only: true log_record: - severity_text: info append_pattern: true body: The integration is unable to read metrics from this endpoint. \ No newline at end of file diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml index 117044e6ee..ba2108c008 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml @@ -22,13 +22,11 @@ smartagent/postgresql: - strict: postgres_query_count first_only: true log_record: - severity_text: info body: PostgreSQL receiver is working! partial: - strict: postgres_rows_inserted first_only: true log_record: - severity_text: info body: >- Make sure that `CREATE EXTENSION IF NOT EXISTS pg_stat_statements;` @@ -40,20 +38,17 @@ smartagent/postgresql: - regexp: 'connect: network is unreachable' first_only: true log_record: - severity_text: info append_pattern: true body: The container cannot be reached by the Collector. Make sure they're in the same network. - regexp: 'connect: connection refused' first_only: true log_record: - severity_text: info append_pattern: true body: The container is refusing PostgreSQL connections. partial: - regexp: 'pq: password authentication failed for user' first_only: true log_record: - severity_text: info append_pattern: true body: >- Please ensure your user credentials are correctly specified with @@ -64,7 +59,6 @@ smartagent/postgresql: - regexp: 'pq: database .* does not exist' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure the target database is correctly specified using the @@ -73,7 +67,6 @@ smartagent/postgresql: - regexp: 'pq: pg_stat_statements must be loaded via shared_preload_libraries' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your PostgreSQL database has diff --git a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml.tmpl b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml.tmpl index 6fab6001ca..27c4da4d3e 100644 --- a/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml.tmpl +++ b/internal/confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml.tmpl @@ -18,13 +18,11 @@ - strict: postgres_query_count first_only: true log_record: - severity_text: info body: PostgreSQL receiver is working! partial: - strict: postgres_rows_inserted first_only: true log_record: - severity_text: info body: >- Make sure that `CREATE EXTENSION IF NOT EXISTS pg_stat_statements;` @@ -36,20 +34,17 @@ - regexp: 'connect: network is unreachable' first_only: true log_record: - severity_text: info append_pattern: true body: The container cannot be reached by the Collector. Make sure they're in the same network. - regexp: 'connect: connection refused' first_only: true log_record: - severity_text: info append_pattern: true body: The container is refusing PostgreSQL connections. partial: - regexp: 'pq: password authentication failed for user' first_only: true log_record: - severity_text: info append_pattern: true body: >- Please ensure your user credentials are correctly specified with @@ -60,7 +55,6 @@ - regexp: 'pq: database .* does not exist' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure the target database is correctly specified using the @@ -69,7 +63,6 @@ - regexp: 'pq: pg_stat_statements must be loaded via shared_preload_libraries' first_only: true log_record: - severity_text: info append_pattern: true body: >- Make sure your PostgreSQL database has diff --git a/internal/confmapprovider/discovery/config_test.go b/internal/confmapprovider/discovery/config_test.go index 50541c0c52..486603ee7f 100644 --- a/internal/confmapprovider/discovery/config_test.go +++ b/internal/confmapprovider/discovery/config_test.go @@ -241,8 +241,7 @@ var expectedConfig = Config{ "strict": "postgres_block_hit_ratio", "first_only": true, "log_record": map[any]any{ - "severity_text": "info", - "body": "postgresql SA receiver working!", + "body": "postgresql SA receiver working!", }, }, }, @@ -253,8 +252,7 @@ var expectedConfig = Config{ "regexp": ".* connect: connection refused", "first_only": true, "log_record": map[any]any{ - "severity_text": "info", - "body": "container appears to not be accepting postgres connections", + "body": "container appears to not be accepting postgres connections", }, }, }, @@ -263,7 +261,6 @@ var expectedConfig = Config{ "regexp": ".*pq: password authentication failed for user.*", "first_only": true, "log_record": map[any]any{ - "severity_text": "info", "body": "Please ensure that your password is correctly specified " + "in `splunk.discovery.receivers.smartagent/postgresql.config.params.username` and " + "`splunk.discovery.receivers.smartagent/postgresql.config.params.password`", @@ -296,8 +293,7 @@ var expectedConfig = Config{ "regexp": ".*", "first_only": true, "log_record": map[any]any{ - "severity_text": "info", - "body": "smartagent/collectd-redis receiver successful metric status", + "body": "smartagent/collectd-redis receiver successful metric status", }, }, }, @@ -308,16 +304,14 @@ var expectedConfig = Config{ "regexp": `raise ValueError\(\"Unknown Redis response`, "first_only": true, "log_record": map[any]any{ - "severity_text": "info", - "body": "container appears to not actually be redis", + "body": "container appears to not actually be redis", }, }, map[any]any{ "regexp": "^redis_info plugin: Error connecting to .* - ConnectionRefusedError.*$", "first_only": true, "log_record": map[any]any{ - "severity_text": "info", - "body": "container appears to not be accepting redis connections", + "body": "container appears to not be accepting redis connections", }, }, }, @@ -326,7 +320,6 @@ var expectedConfig = Config{ "regexp": "^redis_info plugin: Error .* - RedisError\\('-(WRONGPASS|NOAUTH|ERR AUTH).*$", "first_only": true, "log_record": map[any]any{ - "severity_text": "info", "body": "Please ensure that your redis password is correctly specified in " + "`splunk.discovery.receivers.smartagent/collectd/redis.config.auth` or via the " + "`SPLUNK_DISCOVERY_RECEIVERS_SMARTAGENT_COLLECTD_REDIS_CONFIG_AUTH` environment variable.", diff --git a/internal/confmapprovider/discovery/testdata/config.d/receivers/smartagent-collectd-redis.discovery.yaml b/internal/confmapprovider/discovery/testdata/config.d/receivers/smartagent-collectd-redis.discovery.yaml index d28c4cff38..c7beb05a9e 100644 --- a/internal/confmapprovider/discovery/testdata/config.d/receivers/smartagent-collectd-redis.discovery.yaml +++ b/internal/confmapprovider/discovery/testdata/config.d/receivers/smartagent-collectd-redis.discovery.yaml @@ -13,25 +13,21 @@ smartagent/collectd/redis: - regexp: '.*' first_only: true log_record: - severity_text: info body: smartagent/collectd-redis receiver successful metric status statements: failed: - regexp: 'raise ValueError\(\"Unknown Redis response' first_only: true log_record: - severity_text: info body: container appears to not actually be redis - regexp: '^redis_info plugin: Error connecting to .* - ConnectionRefusedError.*$' first_only: true log_record: - severity_text: info body: container appears to not be accepting redis connections partial: - regexp: "^redis_info plugin: Error .* - RedisError\\('-(WRONGPASS|NOAUTH|ERR AUTH).*$" first_only: true log_record: - severity_text: info body: >- Please ensure that your redis password is correctly specified in `splunk.discovery.receivers.smartagent/collectd/redis.config.auth` or via the `SPLUNK_DISCOVERY_RECEIVERS_SMARTAGENT_COLLECTD_REDIS_CONFIG_AUTH` environment variable. diff --git a/internal/confmapprovider/discovery/testdata/config.d/receivers/smartagent-postgres.discovery.yaml b/internal/confmapprovider/discovery/testdata/config.d/receivers/smartagent-postgres.discovery.yaml index 9ebbffa3d7..ce6c3ab5a6 100644 --- a/internal/confmapprovider/discovery/testdata/config.d/receivers/smartagent-postgres.discovery.yaml +++ b/internal/confmapprovider/discovery/testdata/config.d/receivers/smartagent-postgres.discovery.yaml @@ -20,20 +20,17 @@ smartagent/postgresql: - strict: postgres_block_hit_ratio first_only: true log_record: - severity_text: info body: postgresql SA receiver working! statements: failed: - regexp: '.* connect: connection refused' first_only: true log_record: - severity_text: info body: container appears to not be accepting postgres connections partial: - regexp: '.*pq: password authentication failed for user.*' first_only: true log_record: - severity_text: info body: >- Please ensure that your password is correctly specified in `splunk.discovery.receivers.smartagent/postgresql.config.params.username` and `splunk.discovery.receivers.smartagent/postgresql.config.params.password` diff --git a/internal/receiver/discoveryreceiver/README.md b/internal/receiver/discoveryreceiver/README.md index 4ff8e715a6..9bd1384343 100644 --- a/internal/receiver/discoveryreceiver/README.md +++ b/internal/receiver/discoveryreceiver/README.md @@ -155,20 +155,17 @@ receivers: // Only emit a single log record for this status entry instead of one for each matching received metric (`false`, the default) first_only: true log_record: - severity_text: info body: Successfully able to connect to Redis container. statements: partial: - regexp: (WRONGPASS|NOAUTH|ERR AUTH) first_only: true log_record: - severity_text: warn body: Container appears to be accepting redis connections but the default auth setting is incorrect. failed: - regexp: ConnectionRefusedError first_only: true log_record: - severity_text: debug body: Container appears to not be accepting redis connections. exporters: debug: @@ -351,7 +348,6 @@ expr: 'ExprEnv["some.field.with.periods"] contains "value"' | Name | Type | Default | Docs | |------------------|-------------------|---------------------------------------------------------|-----------------------------------------------------------------------------| -| `severity_text` | string | Emitted log statement severity level, if any, or "info" | The emitted log record's severity text | | `body` | string | Emitted log statement message | The emitted log record's body | | `attributes` | map[string]string | Emitted log statements fields | The emitted log record's attributes | | `append_pattern` | bool | false | Whether to append the evaluated statement to the configured log record body | diff --git a/internal/receiver/discoveryreceiver/config.go b/internal/receiver/discoveryreceiver/config.go index 08267720d7..893fe72a7c 100644 --- a/internal/receiver/discoveryreceiver/config.go +++ b/internal/receiver/discoveryreceiver/config.go @@ -89,7 +89,6 @@ type Match struct { // LogRecord is a definition of the desired plog.LogRecord content to emit for a match. type LogRecord struct { Attributes map[string]string `mapstructure:"attributes"` - SeverityText string `mapstructure:"severity_text"` Body string `mapstructure:"body"` AppendPattern bool `mapstructure:"append_pattern"` } @@ -162,20 +161,12 @@ func (s *Status) validate() error { "`%s` status source type `%s` match type validation failed. Must provide one of %v but received %v", statusSource.sourceType, statusType, allowedMatchTypes, matchTypes, )) } - if e := logMatch.Record.validate(); e != nil { - err = multierr.Combine(err, fmt.Errorf(" %q log record validation failure: %w", statusType, e)) - } } } } return err } -func (lr *LogRecord) validate() error { - // TODO: supported severity text validation - return nil -} - // receiverCreatorFactoryAndConfig will embed the applicable receiver creator fields in a new receiver creator config // suitable for being used to create a receiver instance by the returned factory. func (cfg *Config) receiverCreatorFactoryAndConfig(correlations correlationStore) (receiver.Factory, component.Config, error) { diff --git a/internal/receiver/discoveryreceiver/config_test.go b/internal/receiver/discoveryreceiver/config_test.go index 5126896932..0fda553d12 100644 --- a/internal/receiver/discoveryreceiver/config_test.go +++ b/internal/receiver/discoveryreceiver/config_test.go @@ -64,8 +64,7 @@ func TestValidConfig(t *testing.T) { "attr_one": "attr_one_val", "attr_two": "attr_two_val", }, - SeverityText: "info", - Body: "smartagent/redis receiver successful status", + Body: "smartagent/redis receiver successful status", }, Strict: "", Regexp: ".*", @@ -82,9 +81,8 @@ func TestValidConfig(t *testing.T) { Expr: "", FirstOnly: true, Record: &LogRecord{ - Attributes: map[string]string{}, - SeverityText: "info", - Body: "container appears to not be accepting redis connections", + Attributes: map[string]string{}, + Body: "container appears to not be accepting redis connections", }, }, }, @@ -95,9 +93,8 @@ func TestValidConfig(t *testing.T) { Expr: "", FirstOnly: false, Record: &LogRecord{ - Attributes: nil, - SeverityText: "warn", - Body: "desired log invalid auth log body", + Attributes: nil, + Body: "desired log invalid auth log body", }, }, }, diff --git a/internal/receiver/discoveryreceiver/metric_evaluator.go b/internal/receiver/discoveryreceiver/metric_evaluator.go index 117d95cb3e..57c3dc95ab 100644 --- a/internal/receiver/discoveryreceiver/metric_evaluator.go +++ b/internal/receiver/discoveryreceiver/metric_evaluator.go @@ -148,11 +148,6 @@ func (m *metricEvaluator) evaluateMetrics(md pmetric.Metrics) plog.Logs { for k, v := range desiredRecord.Attributes { logRecord.Attributes().PutStr(k, v) } - severityText := desiredRecord.SeverityText - if severityText == "" { - severityText = "info" - } - logRecord.SetSeverityText(severityText) logRecord.Attributes().PutStr(metricNameAttr, metricName) logRecord.Attributes().PutStr(discovery.StatusAttr, string(status)) if ts := m.timestampFromMetric(metric); ts != nil { diff --git a/internal/receiver/discoveryreceiver/statement_evaluator.go b/internal/receiver/discoveryreceiver/statement_evaluator.go index 7ada7f53b1..4a23585628 100644 --- a/internal/receiver/discoveryreceiver/statement_evaluator.go +++ b/internal/receiver/discoveryreceiver/statement_evaluator.go @@ -32,10 +32,7 @@ import ( var _ zapcore.Core = (*statementEvaluator)(nil) -const ( - statementMatch = "statement.match" - defaultSeverityText = "INFO" -) +const statementMatch = "statement.match" // statementEvaluator conforms to a zapcore.Core to intercept component log statements and // determine if they match any configured Status match rules. If so, they emit log records @@ -209,14 +206,6 @@ func (se *statementEvaluator) evaluateStatement(statement *statussources.Stateme logRecord.Attributes().PutStr(k, v) } } - severityText := desiredRecord.SeverityText - if severityText == "" { - severityText = logRecord.SeverityText() - if severityText == "" { - severityText = defaultSeverityText - } - } - logRecord.SetSeverityText(severityText) logRecord.Attributes().PutStr(discovery.StatusAttr, string(status)) logRecord.SetTimestamp(pcommon.NewTimestampFromTime(statement.Time)) logRecord.SetObservedTimestamp(pcommon.NewTimestampFromTime(time.Now())) diff --git a/internal/receiver/discoveryreceiver/statement_evaluator_test.go b/internal/receiver/discoveryreceiver/statement_evaluator_test.go index ddd23d3e73..74cba6be54 100644 --- a/internal/receiver/discoveryreceiver/statement_evaluator_test.go +++ b/internal/receiver/discoveryreceiver/statement_evaluator_test.go @@ -29,7 +29,6 @@ import ( "go.uber.org/zap" "github.com/signalfx/splunk-otel-collector/internal/common/discovery" - "github.com/signalfx/splunk-otel-collector/internal/receiver/discoveryreceiver/statussources" ) func TestStatementEvaluation(t *testing.T) { @@ -54,156 +53,128 @@ func TestStatementEvaluation(t *testing.T) { } for _, status := range discovery.StatusTypes { t.Run(string(status), func(t *testing.T) { - for _, level := range []string{"debug", "info", "warn", "error", "fatal", "dpanic", "panic"} { - t.Run(level, func(t *testing.T) { - for _, firstOnly := range []bool{true, false} { - match.FirstOnly = firstOnly - t.Run(fmt.Sprintf("FirstOnly:%v", firstOnly), func(t *testing.T) { - observerID := component.MustNewIDWithName("an_observer", "observer.name") - cfg := &Config{ - Receivers: map[component.ID]ReceiverEntry{ - component.MustNewIDWithName("a_receiver", "receiver.name"): { - Rule: "a.rule", - Status: &Status{Statements: map[discovery.StatusType][]Match{status: {match}}}, - }, - }, - WatchObservers: []component.ID{observerID}, - } - require.NoError(t, cfg.Validate()) - - plogs := make(chan plog.Logs) - - // If debugging tests, replace the Nop Logger with a test instance to see - // all statements. Not in regular use to avoid spamming output. - // logger := zaptest.NewLogger(t) - logger := zap.NewNop() - cStore := newCorrelationStore(logger, time.Hour) - cStore.UpdateEndpoint( - observer.Endpoint{ID: "endpoint.id"}, - addedState, observerID, - ) - - se, err := newStatementEvaluator(logger, component.MustNewID("some_type"), cfg, plogs, cStore) - require.NoError(t, err) - - evaluatedLogger := se.evaluatedLogger.With( - zap.String("name", `a_receiver/receiver.name/receiver_creator/rc.name/{endpoint=""}/endpoint.id`), - ) - - numExpected := 1 - if !firstOnly { - numExpected = 3 - } - - emitted := plog.NewLogs() - wg := sync.WaitGroup{} - wg.Add(numExpected) - - go func() { - for i := 0; i < numExpected; i++ { - logs := <-plogs - if emitted.LogRecordCount() == 0 { - emitted = logs - } else { - logs.ResourceLogs().MoveAndAppendTo(emitted.ResourceLogs()) - } - wg.Done() - } - }() - - logMethod := map[string]func(string, ...zap.Field){ - "debug": evaluatedLogger.Debug, - "info": evaluatedLogger.Info, - "warn": evaluatedLogger.Warn, - "error": evaluatedLogger.Error, - "fatal": evaluatedLogger.Fatal, - "dpanic": evaluatedLogger.DPanic, - "panic": evaluatedLogger.Panic, - }[level] + for _, firstOnly := range []bool{true, false} { + match.FirstOnly = firstOnly + t.Run(fmt.Sprintf("FirstOnly:%v", firstOnly), func(t *testing.T) { + observerID := component.MustNewIDWithName("an_observer", "observer.name") + cfg := &Config{ + Receivers: map[component.ID]ReceiverEntry{ + component.MustNewIDWithName("a_receiver", "receiver.name"): { + Rule: "a.rule", + Status: &Status{Statements: map[discovery.StatusType][]Match{status: {match}}}, + }, + }, + WatchObservers: []component.ID{observerID}, + } + require.NoError(t, cfg.Validate()) + + plogs := make(chan plog.Logs) + + // If debugging tests, replace the Nop Logger with a test instance to see + // all statements. Not in regular use to avoid spamming output. + // logger := zaptest.NewLogger(t) + logger := zap.NewNop() + cStore := newCorrelationStore(logger, time.Hour) + cStore.UpdateEndpoint( + observer.Endpoint{ID: "endpoint.id"}, + addedState, observerID, + ) + + se, err := newStatementEvaluator(logger, component.MustNewID("some_type"), cfg, plogs, cStore) + require.NoError(t, err) + + evaluatedLogger := se.evaluatedLogger.With( + zap.String("name", `a_receiver/receiver.name/receiver_creator/rc.name/{endpoint=""}/endpoint.id`), + ) + + numExpected := 1 + if !firstOnly { + numExpected = 3 + } - for _, statement := range []string{ - "undesired.statement", - "another.undesired.statement", - "desired.statement", - "desired.statement", - "desired.statement", - } { - panicCheck := require.NotPanics - if level == "panic" { - panicCheck = require.Panics - } - panicCheck(t, func() { - logMethod( - statement, - zap.String("field.one", "field.one.value"), - zap.String("field_two", "field.two.value"), - ) - }) + emitted := plog.NewLogs() + wg := sync.WaitGroup{} + wg.Add(numExpected) + + go func() { + for i := 0; i < numExpected; i++ { + logs := <-plogs + if emitted.LogRecordCount() == 0 { + emitted = logs + } else { + logs.ResourceLogs().MoveAndAppendTo(emitted.ResourceLogs()) } + wg.Done() + } + }() + + for _, statement := range []string{ + "undesired.statement", + "another.undesired.statement", + "desired.statement", + "desired.statement", + "desired.statement", + } { + evaluatedLogger.Info( + statement, + zap.String("field.one", "field.one.value"), + zap.String("field_two", "field.two.value"), + ) + } - require.Eventually(t, func() bool { - wg.Wait() - return true - }, 1*time.Second, time.Millisecond) - close(plogs) - - for i := 0; i < numExpected; i++ { - rl := emitted.ResourceLogs().At(i) - rAttrs := rl.Resource().Attributes() - require.Equal(t, map[string]any{ - "discovery.endpoint.id": "endpoint.id", - "discovery.event.type": "statement.match", - "discovery.observer.id": "an_observer/observer.name", - "discovery.receiver.name": "receiver.name", - "discovery.receiver.rule": "a.rule", - "discovery.receiver.type": "a_receiver", - }, rAttrs.AsRaw()) - - sLogs := rl.ScopeLogs() - require.Equal(t, 1, sLogs.Len()) - sl := sLogs.At(0) - lrs := sl.LogRecords() - require.Equal(t, 1, lrs.Len()) - lr := sl.LogRecords().At(0) - - lrAttrs := lr.Attributes().AsRaw() - - require.Contains(t, lrAttrs, "caller") - _, expectedFile, _, _ := runtime.Caller(0) - // runtime doesn't use os.PathSeparator - splitPath := strings.Split(expectedFile, "/") - expectedCaller := splitPath[len(splitPath)-1] - require.Contains(t, lrAttrs["caller"], expectedCaller) - delete(lrAttrs, "caller") - - // argOrder doesn't like this for some reason - // nolint:gocritic - if strings.Contains("error fatal dpanic panic", level) { - require.Contains(t, lrAttrs, "stacktrace") - delete(lrAttrs, "stacktrace") - } - - require.Equal(t, map[string]any{ - "discovery.status": string(status), - "name": `a_receiver/receiver.name/receiver_creator/rc.name/{endpoint=""}/endpoint.id`, - "attr.one": "attr.one.value", - "attr.two": "attr.two.value", - "field.one": "field.one.value", - "field_two": "field.two.value", - }, lrAttrs) - - expected := "desired body content" - if match.Record.AppendPattern { - if match.Strict != "" { - expected = fmt.Sprintf("%s (evaluated \"desired.statement\")", expected) - } else { - expected = fmt.Sprintf("%s (evaluated \"{\\\"field.one\\\":\\\"field.one.value\\\",\\\"field_two\\\":\\\"field.two.value\\\",\\\"message\\\":\\\"desired.statement\\\"}\")", expected) - } - } - require.Equal(t, expected, lr.Body().AsString()) - require.Equal(t, level, lr.SeverityText()) + require.Eventually(t, func() bool { + wg.Wait() + return true + }, 1*time.Second, time.Millisecond) + close(plogs) + + for i := 0; i < numExpected; i++ { + rl := emitted.ResourceLogs().At(i) + rAttrs := rl.Resource().Attributes() + require.Equal(t, map[string]any{ + "discovery.endpoint.id": "endpoint.id", + "discovery.event.type": "statement.match", + "discovery.observer.id": "an_observer/observer.name", + "discovery.receiver.name": "receiver.name", + "discovery.receiver.rule": "a.rule", + "discovery.receiver.type": "a_receiver", + }, rAttrs.AsRaw()) + + sLogs := rl.ScopeLogs() + require.Equal(t, 1, sLogs.Len()) + sl := sLogs.At(0) + lrs := sl.LogRecords() + require.Equal(t, 1, lrs.Len()) + lr := sl.LogRecords().At(0) + + lrAttrs := lr.Attributes().AsRaw() + + require.Contains(t, lrAttrs, "caller") + _, expectedFile, _, _ := runtime.Caller(0) + // runtime doesn't use os.PathSeparator + splitPath := strings.Split(expectedFile, "/") + expectedCaller := splitPath[len(splitPath)-1] + require.Contains(t, lrAttrs["caller"], expectedCaller) + delete(lrAttrs, "caller") + + require.Equal(t, map[string]any{ + "discovery.status": string(status), + "name": `a_receiver/receiver.name/receiver_creator/rc.name/{endpoint=""}/endpoint.id`, + "attr.one": "attr.one.value", + "attr.two": "attr.two.value", + "field.one": "field.one.value", + "field_two": "field.two.value", + }, lrAttrs) + + expected := "desired body content" + if match.Record.AppendPattern { + if match.Strict != "" { + expected = fmt.Sprintf("%s (evaluated \"desired.statement\")", expected) + } else { + expected = fmt.Sprintf("%s (evaluated \"{\\\"field.one\\\":\\\"field.one.value\\\",\\\"field_two\\\":\\\"field.two.value\\\",\\\"message\\\":\\\"desired.statement\\\"}\")", expected) } - }) + } + require.Equal(t, expected, lr.Body().AsString()) } }) } @@ -214,51 +185,3 @@ func TestStatementEvaluation(t *testing.T) { }) } } - -func TestLogRecordDefaultAndArbitrarySeverityText(t *testing.T) { - observerID := component.MustNewIDWithName("an_observer", "observer.name") - cfg := &Config{ - Receivers: map[component.ID]ReceiverEntry{ - component.MustNewIDWithName("a_receiver", "receiver.name"): { - Rule: "a.rule", - Status: &Status{Statements: map[discovery.StatusType][]Match{discovery.Successful: {Match{Strict: "match.me"}}}}, - }, - }, - WatchObservers: []component.ID{observerID}, - } - require.NoError(t, cfg.Validate()) - - plogs := make(chan plog.Logs) - - logger := zap.NewNop() - cStore := newCorrelationStore(logger, time.Hour) - cStore.UpdateEndpoint( - observer.Endpoint{ID: "endpoint.id"}, - addedState, observerID, - ) - - se, err := newStatementEvaluator(logger, component.MustNewID("some_type"), cfg, plogs, cStore) - require.NoError(t, err) - require.NotNil(t, se) - - s := &statussources.Statement{ - Message: "match.me", - Level: "", - Time: time.Now(), - LoggerName: "logger.name", - Fields: map[string]any{ - "name": `a_receiver/receiver.name/receiver_creator/rc.name/{endpoint=""}/endpoint.id`, - }, - } - - logs := se.evaluateStatement(s) - require.Equal(t, 1, logs.LogRecordCount()) - lr := logs.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0) - require.Equal(t, "INFO", lr.SeverityText()) - - s.Level = "arbitrary level used as severity text" - logs = se.evaluateStatement(s) - require.Equal(t, 1, logs.LogRecordCount()) - lr = logs.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0) - require.Equal(t, "arbitrary level used as severity text", lr.SeverityText()) -} diff --git a/internal/receiver/discoveryreceiver/statussources/statements.go b/internal/receiver/discoveryreceiver/statussources/statements.go index 36893d81cc..18efeca708 100644 --- a/internal/receiver/discoveryreceiver/statussources/statements.go +++ b/internal/receiver/discoveryreceiver/statussources/statements.go @@ -44,7 +44,6 @@ var ( type Statement struct { Message string Fields map[string]any - Level string Time time.Time LoggerName string Caller zapcore.EntryCaller @@ -60,7 +59,6 @@ func NewZapCoreEncoder() zapcore.Encoder { func StatementFromZapCoreEntry(encoder zapcore.Encoder, entry zapcore.Entry, fields []zapcore.Field) (*Statement, error) { statement := &Statement{ Message: entry.Message, - Level: entry.Level.String(), Time: entry.Time, LoggerName: entry.LoggerName, Caller: entry.Caller, @@ -94,7 +92,6 @@ func (s *Statement) ToLogRecord() plog.LogRecord { logRecord.SetTimestamp(pcommon.NewTimestampFromTime(s.Time)) logRecord.SetObservedTimestamp(pcommon.NewTimestampFromTime(time.Now())) logRecord.Body().SetStr(s.Message) - logRecord.SetSeverityText(s.Level) logRecord.Attributes().FromRaw(s.Fields) return logRecord } diff --git a/internal/receiver/discoveryreceiver/testdata/config.yaml b/internal/receiver/discoveryreceiver/testdata/config.yaml index 1ef950cbe1..f2a6e6e2eb 100644 --- a/internal/receiver/discoveryreceiver/testdata/config.yaml +++ b/internal/receiver/discoveryreceiver/testdata/config.yaml @@ -21,7 +21,6 @@ discovery/discovery-name: - regexp: '.*' first_only: true log_record: - severity_text: info body: smartagent/redis receiver successful status attributes: attr_one: attr_one_val @@ -32,11 +31,9 @@ discovery/discovery-name: first_only: true log_record: attributes: {} - severity_text: info body: container appears to not be accepting redis connections partial: - regexp: (WRONGPASS|NOAUTH|ERR AUTH) first_only: false log_record: - severity_text: warn body: desired log invalid auth log body diff --git a/tests/general/discoverymode/testdata/docker-observer-config.d/receivers/internal-prometheus.discovery.yaml b/tests/general/discoverymode/testdata/docker-observer-config.d/receivers/internal-prometheus.discovery.yaml index f343afec9a..686b9a6018 100644 --- a/tests/general/discoverymode/testdata/docker-observer-config.d/receivers/internal-prometheus.discovery.yaml +++ b/tests/general/discoverymode/testdata/docker-observer-config.d/receivers/internal-prometheus.discovery.yaml @@ -19,5 +19,4 @@ prometheus_simple: - strict: prometheus_tsdb_time_retentions_total first_only: true log_record: - severity_text: info body: prometheus detected diff --git a/tests/general/discoverymode/testdata/host-observer-config.d/receivers/internal-prometheus.discovery.yaml b/tests/general/discoverymode/testdata/host-observer-config.d/receivers/internal-prometheus.discovery.yaml index 0be2f006b3..cac5863574 100644 --- a/tests/general/discoverymode/testdata/host-observer-config.d/receivers/internal-prometheus.discovery.yaml +++ b/tests/general/discoverymode/testdata/host-observer-config.d/receivers/internal-prometheus.discovery.yaml @@ -22,5 +22,4 @@ prometheus_simple: - strict: otelcol_process_uptime first_only: true log_record: - severity_text: info body: internal collector prometheus exporter detected diff --git a/tests/receivers/discovery/testdata/host_observer_simple_prometheus_config.yaml b/tests/receivers/discovery/testdata/host_observer_simple_prometheus_config.yaml index 2b80b61bfd..6d28846bd2 100644 --- a/tests/receivers/discovery/testdata/host_observer_simple_prometheus_config.yaml +++ b/tests/receivers/discovery/testdata/host_observer_simple_prometheus_config.yaml @@ -23,24 +23,20 @@ receivers: - regexp: ^otelcol_process_uptime$ first_only: true log_record: - severity_text: info body: Successfully connected to prometheus server statements: failed: - strict: Failed to scrape Prometheus endpoint first_only: true log_record: - severity_text: debug body: (strict) Port appears to not be serving prometheus metrics - regexp: '"message":"Failed to scrape Prometheus endpoint"' first_only: true log_record: - severity_text: debug body: (regexp) Port appears to not be serving prometheus metrics - expr: message == 'Failed to scrape Prometheus endpoint' && target_labels contains 'up' first_only: true log_record: - severity_text: debug body: (expr) Port appears to not be serving prometheus metrics watch_observers: diff --git a/tests/receivers/discovery/testdata/resource_logs/host_observer_endpoints.yaml b/tests/receivers/discovery/testdata/resource_logs/host_observer_endpoints.yaml index 94fa9e0d34..fbe2fe394b 100644 --- a/tests/receivers/discovery/testdata/resource_logs/host_observer_endpoints.yaml +++ b/tests/receivers/discovery/testdata/resource_logs/host_observer_endpoints.yaml @@ -6,7 +6,6 @@ resource_logs: scope_logs: - logs: - body: endpoint.added hostport endpoint (host_observer)127.0.0.1-55554-TCP-1 - severity_text: info attributes: command: /otelcol --config /etc/config.yaml endpoint: 127.0.0.1:55554 @@ -17,7 +16,6 @@ resource_logs: transport: TCP type: hostport - body: endpoint.added hostport endpoint (host_observer)[::]-8888-TCP-1 - severity_text: info attributes: command: /otelcol --config /etc/config.yaml endpoint: '[::]:8888' @@ -34,7 +32,6 @@ resource_logs: scope_logs: - logs: - body: endpoint.added hostport endpoint (host_observer/with_name)127.0.0.1-55554-TCP-1 - severity_text: info attributes: command: /otelcol --config /etc/config.yaml endpoint: 127.0.0.1:55554 @@ -45,7 +42,6 @@ resource_logs: transport: TCP type: hostport - body: endpoint.added hostport endpoint (host_observer/with_name)[::]-8888-TCP-1 - severity_text: info attributes: command: /otelcol --config /etc/config.yaml endpoint: '[::]:8888' @@ -62,7 +58,6 @@ resource_logs: scope_logs: - logs: - body: endpoint.added hostport endpoint (host_observer/with/another/name)127.0.0.1-55554-TCP-1 - severity_text: info attributes: command: /otelcol --config /etc/config.yaml endpoint: 127.0.0.1:55554 @@ -73,7 +68,6 @@ resource_logs: transport: TCP type: hostport - body: endpoint.added hostport endpoint (host_observer/with/another/name)[::]-8888-TCP-1 - severity_text: info attributes: command: /otelcol --config /etc/config.yaml endpoint: '[::]:8888' diff --git a/tests/receivers/discovery/testdata/resource_logs/host_observer_simple_prometheus_statuses.yaml b/tests/receivers/discovery/testdata/resource_logs/host_observer_simple_prometheus_statuses.yaml index 3ce25a54fc..cfcc7842c4 100644 --- a/tests/receivers/discovery/testdata/resource_logs/host_observer_simple_prometheus_statuses.yaml +++ b/tests/receivers/discovery/testdata/resource_logs/host_observer_simple_prometheus_statuses.yaml @@ -21,8 +21,6 @@ resource_logs: attributes: discovery.status: successful metric.name: otelcol_process_uptime - severity: 0 - severity_text: info - attributes: discovery.endpoint.id: (host_observer/with_name)[::]-8888-TCP-1 discovery.event.type: metric.match @@ -45,8 +43,6 @@ resource_logs: attributes: discovery.status: successful metric.name: otelcol_process_uptime - severity: 0 - severity_text: info - attributes: discovery.endpoint.id: (host_observer/with/another/name)[::]-8888-TCP-1 discovery.event.type: metric.match @@ -69,8 +65,6 @@ resource_logs: attributes: discovery.status: successful metric.name: otelcol_process_uptime - severity: 0 - severity_text: info - attributes: discovery.endpoint.id: (host_observer)[::]-4318-TCP-1 discovery.event.type: statement.match @@ -88,8 +82,6 @@ resource_logs: kind: receiver name: prometheus_simple//receiver_creator/discovery{endpoint="[::]:4318"}/(host_observer)[::]-4318-TCP-1 target_labels: '{__name__="up", instance="[::]:4318", job="prometheus_simple/[::]:4318"}' - severity: 0 - severity_text: debug - attributes: discovery.endpoint.id: (host_observer/with_name)[::]-4318-TCP-1 discovery.event.type: statement.match @@ -107,8 +99,6 @@ resource_logs: kind: receiver name: prometheus_simple//receiver_creator/discovery{endpoint="[::]:4318"}/(host_observer/with_name)[::]-4318-TCP-1 target_labels: '{__name__="up", instance="[::]:4318", job="prometheus_simple/[::]:4318"}' - severity: 0 - severity_text: debug - attributes: discovery.endpoint.id: (host_observer/with/another/name)[::]-4318-TCP-1 discovery.event.type: statement.match @@ -126,8 +116,6 @@ resource_logs: kind: receiver name: prometheus_simple//receiver_creator/discovery{endpoint="[::]:4318"}/(host_observer/with/another/name)[::]-4318-TCP-1 target_labels: '{__name__="up", instance="[::]:4318", job="prometheus_simple/[::]:4318"}' - severity: 0 - severity_text: debug - attributes: discovery.endpoint.id: (host_observer)[::]-4318-TCP-1 discovery.event.type: statement.match @@ -145,8 +133,6 @@ resource_logs: kind: receiver name: prometheus_simple//receiver_creator/discovery{endpoint="[::]:4318"}/(host_observer)[::]-4318-TCP-1 target_labels: '{__name__="up", instance="[::]:4318", job="prometheus_simple/[::]:4318"}' - severity: 0 - severity_text: debug - attributes: discovery.endpoint.id: (host_observer/with_name)[::]-4318-TCP-1 discovery.event.type: statement.match @@ -164,8 +150,6 @@ resource_logs: kind: receiver name: prometheus_simple//receiver_creator/discovery{endpoint="[::]:4318"}/(host_observer/with_name)[::]-4318-TCP-1 target_labels: '{__name__="up", instance="[::]:4318", job="prometheus_simple/[::]:4318"}' - severity: 0 - severity_text: debug - attributes: discovery.endpoint.id: (host_observer/with/another/name)[::]-4318-TCP-1 discovery.event.type: statement.match @@ -183,8 +167,6 @@ resource_logs: kind: receiver name: prometheus_simple//receiver_creator/discovery{endpoint="[::]:4318"}/(host_observer/with/another/name)[::]-4318-TCP-1 target_labels: '{__name__="up", instance="[::]:4318", job="prometheus_simple/[::]:4318"}' - severity: 0 - severity_text: debug - attributes: discovery.endpoint.id: (host_observer)[::]-4318-TCP-1 discovery.event.type: statement.match @@ -202,8 +184,6 @@ resource_logs: kind: receiver name: prometheus_simple//receiver_creator/discovery{endpoint="[::]:4318"}/(host_observer)[::]-4318-TCP-1 target_labels: '{__name__="up", instance="[::]:4318", job="prometheus_simple/[::]:4318"}' - severity: 0 - severity_text: debug - attributes: discovery.endpoint.id: (host_observer/with_name)[::]-4318-TCP-1 discovery.event.type: statement.match @@ -221,8 +201,6 @@ resource_logs: kind: receiver name: prometheus_simple//receiver_creator/discovery{endpoint="[::]:4318"}/(host_observer/with_name)[::]-4318-TCP-1 target_labels: '{__name__="up", instance="[::]:4318", job="prometheus_simple/[::]:4318"}' - severity: 0 - severity_text: debug - attributes: discovery.endpoint.id: (host_observer/with/another/name)[::]-4318-TCP-1 discovery.event.type: statement.match @@ -240,5 +218,3 @@ resource_logs: kind: receiver name: prometheus_simple//receiver_creator/discovery{endpoint="[::]:4318"}/(host_observer/with/another/name)[::]-4318-TCP-1 target_labels: '{__name__="up", instance="[::]:4318", job="prometheus_simple/[::]:4318"}' - severity: 0 - severity_text: debug diff --git a/tests/testutils/telemetry/logs_test.go b/tests/testutils/telemetry/logs_test.go index 59fb01f4bf..1acdc9f650 100644 --- a/tests/testutils/telemetry/logs_test.go +++ b/tests/testutils/telemetry/logs_test.go @@ -446,5 +446,5 @@ func TestLogContainsAllWithMissingAndEmptyAttributes(t *testing.T) { containsAll, err = received.ContainsAll(*empty) require.False(t, containsAll) require.Error(t, err) - require.Contains(t, err.Error(), "Missing Logs: [body: a string body\nattributes: {}\nseverity: 1\nseverity_text: info\n]") + require.Contains(t, err.Error(), "Missing Logs: [body: a string body\nattributes: {}\nseverity: 1\n]") } diff --git a/tests/testutils/telemetry/testdata/logs/empty-attributes-required.yaml b/tests/testutils/telemetry/testdata/logs/empty-attributes-required.yaml index 7e9679d0c6..f985fb68b2 100644 --- a/tests/testutils/telemetry/testdata/logs/empty-attributes-required.yaml +++ b/tests/testutils/telemetry/testdata/logs/empty-attributes-required.yaml @@ -2,6 +2,5 @@ resource_logs: - scope_logs: - logs: - body: a string body - severity_text: info severity: 1 attributes: {}