Skip to content

Commit

Permalink
Match prometheus export metrics format
Browse files Browse the repository at this point in the history
Links quarkusio#30576

(cherry picked from commit e57f455)
  • Loading branch information
jtama authored and gsmet committed Jan 31, 2023
1 parent 582a23e commit 20a4f0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions docs/src/main/asciidoc/micrometer.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,11 @@ timers, look for `http_server_requests_seconds_count`, `http_server_requests_sec
----
# HELP http_server_requests_seconds
# TYPE http_server_requests_seconds summary
http_server_requests_seconds_count{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}",} 1.0
http_server_requests_seconds_sum{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}",} 0.017385896
http_server_requests_seconds_count{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}"} 1.0
http_server_requests_seconds_sum{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}"} 0.017385896
# HELP http_server_requests_seconds_max
# TYPE http_server_requests_seconds_max gauge
http_server_requests_seconds_max{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}",} 0.017385896
http_server_requests_seconds_max{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}"} 0.017385896
#
----

Expand All @@ -398,6 +398,11 @@ string. For example, setting
`quarkus.micrometer.binder.http-server.match-patterns=/example/prime/[0-9]+=/example/{jellybeans}` would use the value
`/example/{jellybeans}` for the uri attribute any time the requested uri matches `/example/prime/[0-9]+`.

.Exported metrics format

By default, the metrics are exported using the Prometheus format `application/openmetrics-text`,
you can revert to the former format by specifying the `Accept` request header to `plain/text` (`curl -H "Accept: plain/text" localhost:8080/q/metrics/`).

== Using MeterFilter to configure metrics

Micrometer uses `MeterFilter` instances to customize the metrics emitted by `MeterRegistry` instances.
Expand Down
11 changes: 8 additions & 3 deletions docs/src/main/asciidoc/telemetry-micrometer-tutorial.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,21 @@ Dimensional labels are added for the request uri, the HTTP method
----
# HELP http_server_requests_seconds
# TYPE http_server_requests_seconds summary
http_server_requests_seconds_count{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}",} 2.0
http_server_requests_seconds_sum{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}",} 0.017385896
http_server_requests_seconds_count{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}"} 2.0
http_server_requests_seconds_sum{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}"} 0.017385896
# HELP http_server_requests_seconds_max
# TYPE http_server_requests_seconds_max gauge
http_server_requests_seconds_max{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}",} 0.017385896
http_server_requests_seconds_max{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}"} 0.017385896
#
----

NOTE: Metrics appear lazily, you often won't see any data for your endpoint until it is accessed.

.Exported metrics format

By default, the metrics are exported using the Prometheus format `application/openmetrics-text`,
you can revert to the former format by specifying the `Accept` request header to `plain/text` (`curl -H "Accept: plain/text" localhost:8080/q/metrics/`).

== Inject the MeterRegistry

To register meters, you need a reference to the `MeterRegistry` that is configured and maintained by the Micrometer extension.
Expand Down

0 comments on commit 20a4f0d

Please sign in to comment.