diff --git a/internal/receiver/discoveryreceiver/README.md b/internal/receiver/discoveryreceiver/README.md index 4d67c3fe0a..0c8669b1e5 100644 --- a/internal/receiver/discoveryreceiver/README.md +++ b/internal/receiver/discoveryreceiver/README.md @@ -139,7 +139,7 @@ Body: Empty() Attributes: -> otel.entity.id: Map({"discovery.endpoint.id":"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)"}) -> otel.entity.event.type: Str(entity_state) - -> otel.entity.attributes: Map({"discovery.event.type":"metric.match","discovery.message":"Mysql receiver is working!","discovery.observer.id":"k8s_observer","discovery.receiver.rule":"type == \"port\" and port != 33060 and pod.name matches \"(?i)mysql\"","discovery.receiver.type":"mysql","discovery.status":"successful","k8s.namespace.name":"default","k8s.pod.name":"mysql-0","k8s.pod.uid":"05c6a212-730c-4295-8dd6-0c460c892034","metric.name":"mysql.locks","mysql.instance.endpoint":"192.168.161.105:3306"}) + -> otel.entity.attributes: Map({"discovery.event.type":"metric.match","discovery.message":"Mysql receiver is working!","discovery.observer.id":"k8s_observer","discovery.receiver.type":"mysql","discovery.status":"successful","k8s.namespace.name":"default","k8s.pod.name":"mysql-0","k8s.pod.uid":"05c6a212-730c-4295-8dd6-0c460c892034","metric.name":"mysql.locks","mysql.instance.endpoint":"192.168.161.105:3306"}) Trace ID: Span ID: Flags: 0 @@ -166,7 +166,7 @@ Body: Empty() Attributes: -> otel.entity.id: Map({"discovery.endpoint.id":"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)"}) -> otel.entity.event.type: Str(entity_state) - -> otel.entity.attributes: Map({"caller":"mysqlreceiver@v0.97.0/scraper.go:82","discovery.event.type":"statement.match","discovery.message":"Make sure your user credentials are correctly specified using the `--set splunk.discovery.receivers.mysql.config.username=\"\u003cusername\u003e\"` and `--set splunk.discovery.receivers.mysql.config.password=\"\u003cpassword\u003e\"` command or the `SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_username=\"\u003cusername\u003e\"` and `SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_password=\"\u003cpassword\u003e\"` environment variables. (evaluated \"{\\\"error\\\":\\\"Error 1045 (28000): Access denied for user 'root'@'192.168.174.232' (using password: YES)\\\",\\\"kind\\\":\\\"receiver\\\",\\\"message\\\":\\\"Failed to fetch InnoDB stats\\\"}\")","discovery.observer.id":"k8s_observer","discovery.receiver.name":"","discovery.receiver.rule":"type == \"port\" and port != 33060 and pod.name matches \"(?i)mysql\"","discovery.receiver.type":"mysql","discovery.status":"partial","error":"Error 1045 (28000): Access denied for user 'root'@'192.168.174.232' (using password: YES)","kind":"receiver","name":"mysql//receiver_creator/discovery/logs{endpoint=\"192.168.161.105:3306\"}/k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)","stacktrace":"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver.(*mySQLScraper).scrape\n\tgithub.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver@v0.97.0/scraper.go:82\ngo.opentelemetry.io/collector/receiver/scraperhelper.ScrapeFunc.Scrape\n\tgo.opentelemetry.io/collector/receiver@v0.97.0/scraperhelper/scraper.go:20\ngo.opentelemetry.io/collector/receiver/scraperhelper.(*controller).scrapeMetricsAndReport\n\tgo.opentelemetry.io/collector/receiver@v0.97.0/scraperhelper/scrapercontroller.go:194\ngo.opentelemetry.io/collector/receiver/scraperhelper.(*controller).startScraping.func1\n\tgo.opentelemetry.io/collector/receiver@v0.97.0/scraperhelper/scrapercontroller.go:169"}) + -> otel.entity.attributes: Map({"caller":"mysqlreceiver@v0.97.0/scraper.go:82","discovery.event.type":"statement.match","discovery.message":"Make sure your user credentials are correctly specified using the `--set splunk.discovery.receivers.mysql.config.username=\"\u003cusername\u003e\"` and `--set splunk.discovery.receivers.mysql.config.password=\"\u003cpassword\u003e\"` command or the `SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_username=\"\u003cusername\u003e\"` and `SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_password=\"\u003cpassword\u003e\"` environment variables. (evaluated \"{\\\"error\\\":\\\"Error 1045 (28000): Access denied for user 'root'@'192.168.174.232' (using password: YES)\\\",\\\"kind\\\":\\\"receiver\\\",\\\"message\\\":\\\"Failed to fetch InnoDB stats\\\"}\")","discovery.observer.id":"k8s_observer","discovery.receiver.name":"","discovery.receiver.type":"mysql","discovery.status":"partial","error":"Error 1045 (28000): Access denied for user 'root'@'192.168.174.232' (using password: YES)","kind":"receiver","name":"mysql//receiver_creator/discovery/logs{endpoint=\"192.168.161.105:3306\"}/k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)","stacktrace":"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver.(*mySQLScraper).scrape\n\tgithub.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver@v0.97.0/scraper.go:82\ngo.opentelemetry.io/collector/receiver/scraperhelper.ScrapeFunc.Scrape\n\tgo.opentelemetry.io/collector/receiver@v0.97.0/scraperhelper/scraper.go:20\ngo.opentelemetry.io/collector/receiver/scraperhelper.(*controller).scrapeMetricsAndReport\n\tgo.opentelemetry.io/collector/receiver@v0.97.0/scraperhelper/scrapercontroller.go:194\ngo.opentelemetry.io/collector/receiver/scraperhelper.(*controller).startScraping.func1\n\tgo.opentelemetry.io/collector/receiver@v0.97.0/scraperhelper/scrapercontroller.go:169"}) Trace ID: Span ID: Flags: 0 @@ -192,7 +192,7 @@ Body: Empty() Attributes: -> otel.entity.id: Map({"discovery.endpoint.id":"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)"}) -> otel.entity.event.type: Str(entity_state) - -> otel.entity.attributes: Map({"caller":"receivercreator@v0.97.0/observerhandler.go:96","discovery.event.type":"statement.match","discovery.message":"The container cannot be reached by the Collector. The container is refusing MySQL connections. (evaluated \"{\\\"endpoint\\\":\\\"192.168.161.105:3306\\\",\\\"endpoint_id\\\":\\\"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)\\\",\\\"kind\\\":\\\"receiver\\\",\\\"message\\\":\\\"starting receiver\\\"}\")","discovery.observer.id":"k8s_observer","discovery.receiver.name":"","discovery.receiver.rule":"type == \"port\" and port != 33060 and pod.name matches \"(?i)mysql\"","discovery.receiver.type":"mysql","discovery.status":"failed","endpoint":"192.168.161.105:3306","endpoint_id":"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)","kind":"receiver","name":"mysql"}) + -> otel.entity.attributes: Map({"caller":"receivercreator@v0.97.0/observerhandler.go:96","discovery.event.type":"statement.match","discovery.message":"The container cannot be reached by the Collector. The container is refusing MySQL connections. (evaluated \"{\\\"endpoint\\\":\\\"192.168.161.105:3306\\\",\\\"endpoint_id\\\":\\\"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)\\\",\\\"kind\\\":\\\"receiver\\\",\\\"message\\\":\\\"starting receiver\\\"}\")","discovery.observer.id":"k8s_observer","discovery.receiver.name":"","discovery.receiver.type":"mysql","discovery.status":"failed","endpoint":"192.168.161.105:3306","endpoint_id":"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)","kind":"receiver","name":"mysql"}) Trace ID: Span ID: Flags: 0 diff --git a/internal/receiver/discoveryreceiver/config.go b/internal/receiver/discoveryreceiver/config.go index 0af21ea204..472455a5d4 100644 --- a/internal/receiver/discoveryreceiver/config.go +++ b/internal/receiver/discoveryreceiver/config.go @@ -185,7 +185,6 @@ func (cfg *Config) receiverCreatorReceiversConfig() map[string]any { } resourceAttributes[discovery.ReceiverNameAttr] = receiverID.Name() resourceAttributes[discovery.ReceiverTypeAttr] = receiverID.Type().String() - resourceAttributes[receiverRuleAttr] = rEntry.Rule.String() resourceAttributes[discovery.EndpointIDAttr] = "`id`" rEntryMap := map[string]any{} diff --git a/internal/receiver/discoveryreceiver/config_test.go b/internal/receiver/discoveryreceiver/config_test.go index 3a9fb6ff09..0b38fb288a 100644 --- a/internal/receiver/discoveryreceiver/config_test.go +++ b/internal/receiver/discoveryreceiver/config_test.go @@ -163,7 +163,6 @@ func TestReceiverCreatorFactoryAndConfig(t *testing.T) { "resource_attributes": map[string]string{ "discovery.endpoint.id": "`id`", "discovery.receiver.name": "redis", - "discovery.receiver.rule": `type == "container" && name matches "(?i)redis"`, "discovery.receiver.type": "smartagent", "receiver_attribute": "receiver_attribute_value", }, diff --git a/internal/receiver/discoveryreceiver/metric_evaluator.go b/internal/receiver/discoveryreceiver/metric_evaluator.go index 3f2e73afe6..c6edac4240 100644 --- a/internal/receiver/discoveryreceiver/metric_evaluator.go +++ b/internal/receiver/discoveryreceiver/metric_evaluator.go @@ -125,7 +125,6 @@ func (m *metricsConsumer) evaluateMetrics(md pmetric.Metrics) { }) m.correlateResourceAttributes(m.config, attrs, corr) - attrs[receiverRuleAttr] = rEntry.Rule.String() attrs[discovery.MessageAttr] = match.Message attrs[discovery.StatusAttr] = string(match.Status) m.correlations.UpdateAttrs(endpointID, attrs) diff --git a/internal/receiver/discoveryreceiver/metric_evaluator_test.go b/internal/receiver/discoveryreceiver/metric_evaluator_test.go index 29b74d372c..d73d84e4ef 100644 --- a/internal/receiver/discoveryreceiver/metric_evaluator_test.go +++ b/internal/receiver/discoveryreceiver/metric_evaluator_test.go @@ -124,7 +124,6 @@ func TestMetricEvaluation(t *testing.T) { require.Equal(t, map[string]string{ "discovery.observer.id": "an_observer/observer.name", "discovery.receiver.name": "receiver.name", - "discovery.receiver.rule": "a.rule", "discovery.receiver.type": "a_receiver", "discovery.status": string(status), "discovery.message": "desired body content", diff --git a/internal/receiver/discoveryreceiver/receiver.go b/internal/receiver/discoveryreceiver/receiver.go index 577ad1aa57..64f933300a 100644 --- a/internal/receiver/discoveryreceiver/receiver.go +++ b/internal/receiver/discoveryreceiver/receiver.go @@ -35,7 +35,6 @@ import ( const ( observerNameAttr = "discovery.observer.name" observerTypeAttr = "discovery.observer.type" - receiverRuleAttr = "discovery.receiver.rule" matchedLogAttr = "discovery.matched_log" ) diff --git a/internal/receiver/discoveryreceiver/statement_evaluator.go b/internal/receiver/discoveryreceiver/statement_evaluator.go index b06f1e0835..159617d802 100644 --- a/internal/receiver/discoveryreceiver/statement_evaluator.go +++ b/internal/receiver/discoveryreceiver/statement_evaluator.go @@ -186,7 +186,6 @@ func (se *statementEvaluator) evaluateStatement(statement *statussources.Stateme attrs[discovery.ReceiverTypeAttr] = receiverID.Type().String() attrs[discovery.ReceiverNameAttr] = receiverID.Name() attrs[discovery.MessageAttr] = statement.Message - attrs[receiverRuleAttr] = rEntry.Rule.String() attrs[discovery.MessageAttr] = match.Message // set original message as "discovery.matched_log" attribute diff --git a/internal/receiver/discoveryreceiver/statement_evaluator_test.go b/internal/receiver/discoveryreceiver/statement_evaluator_test.go index 0f6a9ce5db..8828ec837e 100644 --- a/internal/receiver/discoveryreceiver/statement_evaluator_test.go +++ b/internal/receiver/discoveryreceiver/statement_evaluator_test.go @@ -102,7 +102,6 @@ func TestStatementEvaluation(t *testing.T) { require.Equal(t, map[string]string{ "discovery.observer.id": "an_observer/observer.name", "discovery.receiver.name": "receiver.name", - "discovery.receiver.rule": `type == "container"`, "discovery.receiver.type": "a_receiver", "discovery.status": string(status), "discovery.message": "desired body content", 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 cfed9ee3c6..200405033b 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 @@ -10,7 +10,6 @@ resource_logs: discovery.endpoint.id: (host_observer)[::]-8888-TCP-1 discovery.observer.id: host_observer discovery.receiver.config: cmVjZWl2ZXJzOgogIHByb21ldGhldXNfc2ltcGxlOgogICAgY29uZmlnOiB7fQogICAgcmVzb3VyY2VfYXR0cmlidXRlczoKICAgICAgb25lLmtleTogb25lLnZhbHVlCiAgICAgIHR3by5rZXk6IHR3by52YWx1ZQogICAgcnVsZTogdHlwZSA9PSAiaG9zdHBvcnQiIGFuZCBjb21tYW5kIGNvbnRhaW5zICJvdGVsY29sIgp3YXRjaF9vYnNlcnZlcnM6Ci0gaG9zdF9vYnNlcnZlcgo= - discovery.receiver.rule: type == "hostport" and command contains "otelcol" discovery.receiver.type: prometheus_simple http.scheme: http net.host.port: "8888" @@ -46,7 +45,6 @@ resource_logs: discovery.observer.id: host_observer discovery.receiver.config: cmVjZWl2ZXJzOgogIHByb21ldGhldXNfc2ltcGxlOgogICAgY29uZmlnOiB7fQogICAgcmVzb3VyY2VfYXR0cmlidXRlczoKICAgICAgb25lLmtleTogb25lLnZhbHVlCiAgICAgIHR3by5rZXk6IHR3by52YWx1ZQogICAgcnVsZTogdHlwZSA9PSAiaG9zdHBvcnQiIGFuZCBjb21tYW5kIGNvbnRhaW5zICJvdGVsY29sIgp3YXRjaF9vYnNlcnZlcnM6Ci0gaG9zdF9vYnNlcnZlcgo= discovery.receiver.name: "" - discovery.receiver.rule: type == "hostport" and command contains "otelcol" discovery.receiver.type: prometheus_simple discovery.status: failed discovery.message: (strict) Port appears to not be serving prometheus metrics