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

Prometheus Exporter should have an option to export using OpenMetrics format #3468

Open
paivagustavo opened this issue Nov 14, 2022 · 6 comments
Assignees
Labels
area:metrics Part of OpenTelemetry Metrics enhancement New feature or request pkg:exporter:prometheus Related to the Prometheus exporter package

Comments

@paivagustavo
Copy link
Member

Problem Statement

Prometheus exporter only expose metrics using the Prometheus format, which is a subset of the OpenMetrics format. Ideally, we should be able to specify an option to export metrics using the OpenMetrics format.

Given that we don't expose an OpenMetrics format, we lose information about metric's units, which make some required processing of Prometheus metric to OTLP as the specs define to be skipped, e..g, unit suffixes added by the otel-go are not able to be removed due to the lack of unit information as a limitation of the prometheus format.

Proposed Solution

A prometheus.WithOpenMetrics() option to enable the OpenMetrics format, which should contains unit metadata and implement the OTLP Metric points to Prometheus.

The Unit of an OTLP metric point MUST be added as OpenMetrics UNIT metadata. Additionally, the unit MUST be added as a suffix to the metric name, and SHOULD be converted to base units recommended by OpenMetrics when possible. The unit suffix comes before any type-specific suffixes.

Alternatives

Another alternative would always enable this behavior, but having an option to enable/disabled can be useful.

@paivagustavo paivagustavo added the enhancement New feature or request label Nov 14, 2022
@Aneurysm9 Aneurysm9 added area:metrics Part of OpenTelemetry Metrics priority:p1 pkg:exporter:prometheus Related to the Prometheus exporter package labels Nov 14, 2022
@MadVikingGod
Copy link
Contributor

I explored trying to get prometheus to expose the Unit types, and it looks like the library doesn't do this yet prometheus/client_golang#684.

@MrAlias
Copy link
Contributor

MrAlias commented Feb 2, 2023

This doesn't look to be required for GA, moving to the post-GA project.

@MrAlias
Copy link
Contributor

MrAlias commented Feb 2, 2023

Note from SIG meeting: this will likely depend on the underlying Prometheus library supporting OpenMetrics before we want to also support it.

@dashpole
Copy link
Contributor

dashpole commented Oct 2, 2023

You can use OpenMetrics today with the prometheus exporter. In the example, you can change this line:

http.Handle("/metrics", promhttp.Handler())

To:

http.Handle("/metrics", HandlerFor(prometheus.DefaultGatherer, HandlerOpts{EnableOpenMetrics: true})) 

@dashpole
Copy link
Contributor

dashpole commented Oct 3, 2023

I don't think this blocks the prometheus exporter GA. Adding UNIT metadata to the exporter after the go client has support can be done as an addition later.

@dashpole
Copy link
Contributor

Blocked by prometheus/client_golang#684

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metrics Part of OpenTelemetry Metrics enhancement New feature or request pkg:exporter:prometheus Related to the Prometheus exporter package
Projects
Development

No branches or pull requests

5 participants