quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.58k stars 2.63k forks source link

Enable only JSON export for Micrometer without changing the prometheus metrics doesn't work #34429

Open llowinge opened 1 year ago

llowinge commented 1 year ago

Describe the bug

According to https://quarkus.io/guides/micrometer#management-interface i can enable JSON export with

quarkus.micrometer.export.json.enabled = true
quarkus.micrometer.export.json.path = metrics/json

but that doesn't work (curl "localhost:9000/q/metrics/json" still returns Prometheus format output) unless i add also

quarkus.micrometer.export.prometheus.path = metrics/prometheus

Which looks to me like a bug. Why i cannot specify only the JSON endpoint and benefit from it ?

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

Use these two dependencies

    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-micrometer</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-micrometer-registry-prometheus</artifactId>
    </dependency>

and play with the properties mentioned in description.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.1.3.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
quarkus-bot[bot] commented 1 year ago

/cc @brunobat (micrometer), @ebullient (metrics,micrometer), @jmartisk (metrics)

jmartisk commented 1 year ago

The problem is that the Prometheus endpoint is, by default, configured to listen on /metrics/*, and if you configure JSON to be on /metrics/json, then the paths collide and the Prometheus endpoint seems to take precedence in handling the request. So I guess you either need to completely disable Prometheus (remove the quarkus-micrometer-registry-prometheus dependency) or configure the JSON endpoint to be on a different path that doesn't collide with the Prometheus path - which is what the linked documentation is doing (it changes the Prometheus path to /metrics/prometheus).

llowinge commented 1 year ago

@jmartisk Even if i add quarkus.micrometer.export.prometheus.path = metrics it still returns (on path metrics/json) Prometheus format output. This looks to me like a bug, because it is preventing me to use metrics/json for JSON and metrics for Prometheus. It should atleast be documented, even it looks to me like a bug. Thank you in advance.

Btw. why it is configured to listen on /metrics/* ?

jmartisk commented 1 year ago

I'm not completely sure why it listens on subpaths as well (I think it doesn't allow you to change anything by appending something to the request URL), maybe @ebullient has an explanation