Micrometer Metrics
Overview
The Helidon Micrometer provider backs the neutral Helidon metrics API and configured metrics publishers. It provides:
- a Micrometer-backed Helidon meter registry for application-specific metrics
- the standard
/observe/metricsendpoint, exposed by the metrics observer - configuration for the Prometheus and OTLP metrics publishers.
Application code which needs direct Micrometer API access can unwrap the Micrometer registry from Helidon's service-owned meter registry.
Maven Coordinates
To use the metrics observer and Micrometer API, add the following dependencies
to your project's pom.xml (see Managing
Dependencies).
<dependency>
<groupId>io.helidon.webserver.observe</groupId>
<artifactId>helidon-webserver-observe-metrics</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.metrics.providers</groupId>
<artifactId>helidon-metrics-providers-micrometer</artifactId>
</dependency>
The first dependency adds the metrics observer and the /observe/metrics
endpoint. It includes Helidon's Micrometer-based metrics implementation at
runtime. The second dependency makes the Micrometer API available when
compiling application code which uses Micrometer types directly, as the
examples on this page do.
Usage
Application code can create, look up, and update meters programmatically using
the Micrometer MeterRegistry API. The Micrometer concepts
documentation provides an introduction to Micrometer's
interfaces and classes.
Metrics.globalRegistry as
its backing registry. Applications upgrading from earlier Helidon versions
which registered meters with Metrics.globalRegistry must switch to
Helidon's service-owned registry; otherwise, Helidon's configured metrics
publishers do not expose those meters. Obtain Helidon's
io.helidon.metrics.api.MeterRegistry using injection or
Services.get(io.helidon.metrics.api.MeterRegistry.class) and invoke
unwrap(io.micrometer.core.instrument.MeterRegistry.class).The following example obtains Helidon's service-owned Micrometer registry and passes it to an HTTP service.
Register a MeterRegistry-backed Service with the Web Server
Create and Update Meters in Your Application Service
Configuration
Helidon's Micrometer support is exposed through the Micrometer-backed metrics
publishers. Configure publishers under metrics.publishers or under
server.features.observe.observers.metrics.publishers for observer-specific
settings. If you do not configure any publishers explicitly, Helidon infers a
Prometheus publisher.
Metrics Endpoint
Helidon's metrics observer exposes the service-owned registry through a REST
endpoint, by default at /observe/metrics. See the
Helidon Metrics documentation for supported
response formats and other endpoint behavior.
Override the observer endpoint using its builder or the
server.features.observe.observers.metrics.endpoint configuration key:
server:
features:
observe:
observers:
metrics:
endpoint: my-metrics
Publisher Configuration
Configure the supported publishers by name:
metrics:
publishers:
prometheus:
otlp:
url: http://localhost:4318/v1/metrics
Prometheus Publisher Configuration Options
| Key | Type | Default | Description |
|---|---|---|---|
prefix | String | Prefix for Micrometer Prometheus property lookups; this setting does not add a prefix to exported metric names, and the legacy prometheus. property is accepted for compatibility but ignored with a warning | |
naming- | Prometheus | Prometheus naming convention settings | |
name | String | N/ | |
interval | Duration | Step size used in computing "windowed" statistics | |
descriptions | Boolean | Whether to include meter descriptions in Prometheus output | |
enabled | Boolean | true | Whether the configured publisher is enabled |
OTLP Publisher Configuration Options
| Key | Type | Default | Description |
|---|---|---|---|
headers | Map< | Headers to add to each transmission message | |
base- | Time | java. | Base time unit for timers |
prefix | String | otlp | The prefix for settings |
aggregation- | Aggregation | CUMULATIVE | Algorithm to use for adjusting values before transmission |
enabled | Boolean | true | Whether the configured publisher is enabled |
url | String | http: | URL to which to send metrics telemetry |
max- | Integer | 20 | Maximum scale value to apply to statistical histogram |
batch- | Integer | 10000 | Number of measurements to send in a single request to the backend |
max- | Integer | 160 | Maximum bucket count to apply to statistical histogram |
name | String | N/ | |
interval | Duration | PT60s | Interval between successive transmissions of metrics data |
max- | Map< | Maximum number of buckets to use for specific meters | |
properties | Map< | Property values to be returned by the OTLP meter registry configuration | |
resource- | Map< | Attribute name/value pairs to be associated with all metrics transmissions |
Additional Information
The Micrometer website describes the project and links to further documentation.