Open pratik2294 opened 1 week ago
Pinging code owners:
exporter/prometheus: @Aneurysm9 @dashpole
See Adding Labels via Comments if you do not have permissions to add labels yourself.
Similar to https://github.com/open-telemetry/opentelemetry-go/pull/5755, we should switch the prometheus exporter to use model.EscapeName
, which I think should fix this.
Component(s)
exporter/prometheus
What happened?
Description
Using Open Telemetry Java sdk, when i create a metric with name of format
myprefix___l1_l2_actualName
, then otel collector displays the metric on its Prometheus exporter asmyprefix_l1_l2_actualName
. (Underscores are reduced)myprefix___l1_l2_actualName
is a valid metric name according to Prometheus Data Model.myprefix___l1_l2_actualName
does match the provided regex[a-zA-Z_:][a-zA-Z0-9_:]*
according to prometheus data model. This can be verified with Regex 101 with PCRE PHP <7.3. Also this metric doesn't start with "__" (double underscores) which are reserved for internal use as per Prometheus' Metric names and labels guidelines. Hence it is a valid metric name.If I use File exporter instead of Prometheus exporter then the expected name of the metric is observed in the file. See the Otel configuration provided in the issue.
Steps to Reproduce Using Otel Java SDK.
Expected Result
Metric with name
myprefix___l1_l2_actualName
should be available on collector's 8089/Metrics endpoint. (Maintain all the given underscores).Actual Result
Metric with name
myprefix_l1_l2_actualName
is be available on collector's 8089/Metrics endpoint.Collector version
v0.104.0
Environment information
Environment
OS: (e.g., "Ubuntu 20.04") Compiler(if manually compiled): (e.g., "go 14.2") I was using docker image "otel/opentelemetry-collector-contrib:0.104.0-amd64"
OpenTelemetry Collector configuration
Log output
Additional context
This affects backward compatibility in as the name of the metric that appears on collector's prometheus exporter (/metrics) is different from the one that was originally in use. All the existing Grafana dashboards and Prometheus alerts will be affected as the metric name is has less underscores.