This section describes the REST-API, that monitoring agents would use to retrieve the collected metrics. (Java-) methods mentioned refer to the respective Objects in the Java API. See also app-programming-model.adoc
Note
|
While vendors are required to provide a /metrics endpoint, as described in this section, it is permissible for implementations to be configurable to run without the endpoint in cases where the metrics capability is not wanted or a different monitoring backend is in use that does not require the endpoint.
|
The REST API must respond to GET requests with data formatted according to the Prometheus text-based exposition format, version 0.0.4 (hereafter Prometheus format). For details of how to format metrics data in this format, see Prometheus format.
Implementations may additionally provide the ability to respond to GET requests with data formatted according to the OpenMetrics exposition format, version 1.0 (hereafter OpenMetrics format). For details on how to format metrics data in this format, see OpenMetrics format.
This section provides the details of how to map from the Gauge, Counter, Timer and Histogram types defined in this specification into appropriate fields in the Prometheus format.
Details of how to format metric names, including conventions, special character mapping and placement of the unit (if provided) in the name, are as described by the Prometheus format and OpenMetrics format documentation.
Quantile values, as used in Histogram and Timer output, should represent recent values (typically from the last 5-10 minutes). If no data is available from that timeframe, the value must be set to NaN.
celsius
in Prometheus format.# HELP current_temperature_celsius The current temperature. (1)
# TYPE current_temperature_celsius gauge (2)
current_temperature_celsius{_scope="application",server="front_office"} 36.2 (3)
-
The description of the gauge, from the
getDescription()
method of theMetadata
associated to the gauge, must be provided in the HELP line -
The type of the metric, in this case
gauge
, must be shown in the TYPE line -
The value specified must be the value of the gauge’s
getValue()
method. Tags, if provided, are included in brackets separated by commas.
events
in Prometheus format.# HELP messages_processed_events_total Number of messages handled (1)
# TYPE messages_processed_events_total counter (2)
messages_processed_events_total{_scope="application"} 1.0 (3)
-
The description of the counter must be provided in the HELP line
-
The type of the metric, in this case
counter
, must be shown in the TYPE line -
The value specified must be the value of the counter’s
getCount()
method. Tags, if provided, are included in brackets separated by commas. By convention,_total
should be added to the end of the counter name.
meters
in Prometheus format.# HELP distance_to_hole_meters_max Distance of golf ball to hole (1)
# TYPE distance_to_hole_meters_max gauge (2)
distance_to_hole_meters_max{_scope="golf_stats"} 12.722726616315509 (3)
# HELP distance_to_hole_meters Distance of golf ball to hole (1)
# TYPE distance_to_hole_meters summary (2)
distance_to_hole_meters{_scope="golf_stats",quantile="0.5"} 2.8748779296875 (3)
distance_to_hole_meters{_scope="golf_stats",quantile="0.75"} 4.4998779296875 (3)
distance_to_hole_meters{_scope="golf_stats",quantile="0.95"} 7.9998779296875 (3)
distance_to_hole_meters{_scope="golf_stats",quantile="0.98"} 9.4998779296875 (3)
distance_to_hole_meters{_scope="golf_stats",quantile="0.99"} 11.9998779296875 (3)
distance_to_hole_meters{_scope="golf_stats",quantile="0.999"} 12.9998779296875 (3)
distance_to_hole_meters_count{_scope="golf_stats"} 487.0 (3)
distance_to_hole_meters_sum{_scope="golf_stats"} 1569.3785694223322 (3)
Histogram
output is comprised of a maximum section and a summary section.
-
The description of the histogram must be provided on the HELP lines for the maximum and summary
-
The type of the metrics, in this case
gauge
(for the maximum) andsummary
for the summary. Thesummary
type is comprised of the count, sum and multiple quantile values. -
The value of each metric included in the output is described in the table below. Tags, if provided, are included in brackets separated by commas. Percentile metrics include a
quantile
label that is merged with the metric’s tags.
Suffix{label} | TYPE | Value (Histogram method) | Units |
---|---|---|---|
|
Gauge |
|
<units> |
|
Summary |
|
<units> |
|
Summary |
|
<units> |
|
Summary |
|
<units> |
|
Summary |
|
<units> |
|
Summary |
|
<units> |
|
Summary |
|
<units> |
|
Summary |
|
<units> |
|
Summary |
|
<units> |
seconds
as the unit.# HELP myClass_myMethod_seconds duration of myMethod (1)
# TYPE myClass_myMethod_seconds summary (2)
myClass_myMethod_seconds{_scope="vendor",quantile="0.5"} 0.0524288 (3)
myClass_myMethod_seconds{_scope="vendor",quantile="0.75"} 0.0524288 (3)
myClass_myMethod_seconds{_scope="vendor",quantile="0.95"} 0.054525952 (3)
myClass_myMethod_seconds{_scope="vendor",quantile="0.98"} 0.054525952 (3)
myClass_myMethod_seconds{_scope="vendor",quantile="0.99"} 0.054525952 (3)
myClass_myMethod_seconds{_scope="vendor",quantile="0.999"} 0.054525952 (3)
myClass_myMethod_seconds_count{_scope="vendor"} 100.0 (3)
myClass_myMethod_seconds_sum{_scope="vendor"} 5.310349419 (3)
# HELP myClass_myMethod_seconds_max duration of myMethod (1)
# TYPE myClass_myMethod_seconds_max gauge (2)
myClass_myMethod_seconds_max{_scope="vendor"} 0.05507899 (3)
Timer
output is comprised of a maximum section and a summary section.
-
The description of the timer must be provided on the HELP lines for the maximum and summary
-
The type of the metrics, in this case
gauge
(for the maximum) andsummary
for the summary. Thesummary
type is comprised of the count, sum and multiple quantile values. -
The value of each metric included in the output is described in the table below. Tags, if provided, are included in brackets separated by commas. Percentile metrics include a
quantile
label that is merged with the metric’s tags.
Suffix{label} | TYPE | Value (Timer method) | Units |
---|---|---|---|
|
Gauge |
|
SECONDS1 |
|
Summary |
|
SECONDS1 |
|
Summary |
|
SECONDS1 |
|
Summary |
|
SECONDS1 |
|
Summary |
|
SECONDS1 |
|
Summary |
|
SECONDS1 |
|
Summary |
|
SECONDS1 |
|
Summary |
|
SECONDS1 |
|
Summary |
|
SECONDS1 |
1 The implementation is expected to convert the result returned by the Timer
into seconds
It must be possible to secure the endpoints via the usual means. The definition of 'usual means' is in this version of the specification implementation specific.
In case of a secured endpoint, accessing /metrics
without valid credentials must return a 401 Unauthorized
header.
A server SHOULD implement TLS encryption by default.
It is allowed to ignore security for trusted origins (e.g. localhost)