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 endpoint does not provide metric name #11

Open
jmesnil opened this issue Oct 15, 2018 · 3 comments
Open

Prometheus endpoint does not provide metric name #11

jmesnil opened this issue Oct 15, 2018 · 3 comments

Comments

@jmesnil
Copy link
Contributor

jmesnil commented Oct 15, 2018

While playing with the jvm.uptime metric, I noticed that the Prometheus endpoint does not contain the actual name of the metric.

$ curl http://127.0.0.1:9990/metrics/base/
...
# HELP base:jvm_uptime_seconds Displays the start time of the Java virtual machine in milliseconds. This attribute displays the approximate time when the Java virtual machine started.
# TYPE base:jvm_uptime_seconds gauge
base:jvm_uptime_seconds 3.277E-4
...

When I tried to get the metric only for `jvm.uptime, I tried the name from the previous result:

$ curl http://127.0.0.1:9990/metrics/base/jvm_uptime_seconds
Metric base/jvm_uptime_seconds not found
$ curl http://127.0.0.1:9990/metrics/base/jvm_uptime
Metric base/jvm_uptime not found

It turns ou that I need to use the original metric name jvm.uptime (which is obvious in retrospect):

$ curl http://127.0.0.1:9990/metrics/base/jvm.uptime
# HELP base:jvm_uptime_seconds Displays the start time of the Java virtual machine in milliseconds. This attribute displays the approximate time when the Java virtual machine started.
# TYPE base:jvm_uptime_seconds gauge
base:jvm_uptime_seconds 1.43104E-4

However there is no way to know the actual metric name from the Prometheus output itself as the metrics/base endpoint only mentions jvm_uptime_seconds and never jvm.uptime.

Could we improve somehow the Prometheus export format so that it is possible to drill down the metric from their scope without having to mentally convert the metric name from MicroProfile to the Prometheus one according to the spec (section 3.2.1. Translation rules for metric names)?

@rsvoboda
Copy link

rsvoboda commented Nov 6, 2018

@kenfinnigan can you look into this or assign appropriate person, please ?

@kenfinnigan
Copy link
Contributor

@rsvoboda It will be looked at when we've scheduled the work

@pilhuhn
Copy link
Contributor

pilhuhn commented Nov 7, 2018

@jmesnil I think I like the idea, can you please open an issue in @eclipse/microprofile-metrics ?
While the spec does not directly talk about this, it is obvious from the OpenMetrics format, that the # HELP line can not just replace the name in OM-format with the original one.

We could just append the original name in parens at the end of the description, but it would not exactly follow the spec ("luckily" there are no tests for the # HELP line :)

A patch should be relatively straight-forward as https://github.com/smallrye/smallrye-metrics/blob/master/implementation/src/main/java/io/smallrye/metrics/exporters/PrometheusExporter.java#L295 is creating the # HELP line and the original metric name should be in the key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants