Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit prometheus exemplar label characters to conform to prometheus limits #6770

Open
jack-berg opened this issue Oct 8, 2024 · 3 comments
Labels
Bug Something isn't working

Comments

@jack-berg
Copy link
Member

jack-berg commented Oct 8, 2024

I ran the agent using java auto-instrument.
Everything seemed to be working fine, but I didn't see any exemplar in grafana.
I checked the error below through the prometheus log.

err="label length for exemplar exceeds maximum of 128 UTF-8 characters"

When I checked the metric, there were too many labels attached to the exemplar.

# client_address="127.0.0.6",network_peer_address="127.0.0.6",network_peer_port="55579",server_address="10.3.17.168",server_port="8081",span_id="049178b29912fdb4",trace_id="0669315b30dbe08683c19ed9bd24068b",url_path="/actuator/health",user_agent_original="kube-probe/1.29+"}

Is there a way to remove the Exemplar's Label?

Originally posted by @myeongseok-rpls in open-telemetry/opentelemetry-java-instrumentation#12411

As discussed in the issue, prometheus has a limit on the allowed characters in exemplars. The java prometheus exporter should not produce exemplars which violate this limit. Currently, the limit appears to be hard coded to 128 characters.

@jack-berg jack-berg added the Bug Something isn't working label Oct 8, 2024
@trask trask transferred this issue from open-telemetry/opentelemetry-java-instrumentation Oct 8, 2024
@harshitrjpt
Copy link

harshitrjpt commented Oct 14, 2024

hi @jack-berg ,
I am working on this by validating the exemplar label runes length in Otel2PrometheusConverter#convertExemplar. (hopefully that's the right direction, do correct me if wrong)

However, when i tried writing the test case by creating a sample Metric data with exemplar, I noticed that io.prometheus.metrics.expositionformats.PrometheusTextFormatWriter#writeCounter is not writing the exemplar labels to the output stream. Do you think this is a bug?

Screenshot 2024-10-14 at 9 56 41 PM

I could not find any tests validating whether exemplar objects's labels are being validated anywhere during otel 2 prometheus conversion.

@harshitrjpt
Copy link

To use exemplars we need to use OpenMetrics exposition format writer. ref: https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md#exemplars-experimental

harshitrjpt added a commit to harshitrjpt/opentelemetry-java that referenced this issue Oct 15, 2024
harshitrjpt added a commit to harshitrjpt/opentelemetry-java that referenced this issue Oct 15, 2024
@jack-berg
Copy link
Member Author

To use exemplars we need to use OpenMetrics exposition format writer. ref: https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md#exemplars-experimental

Yup.

@fstab is this actually an issue with prometheus/client_java? Should the OpenMetricTextFormatWriter limits the characters in exemplar labels to 128 like the golang implementation?

harshitrjpt added a commit to harshitrjpt/opentelemetry-java that referenced this issue Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants