- Prometheus Metrics
Helidon WebServer can serve Prometheus metrics.
This document describes how to register Prometheus support with WebServer and how to customize the configuration. For information about using Prometheus, see the Prometheus documentation: https://prometheus.io/docs/introduction/overview/.
Note that Helidon has an in-built metrics implementation. See Helidon Metrics.
Prerequisites
Declare the following dependency in your project:
<dependency>
<groupId>io.helidon.metrics</groupId>
<artifactId>helidon-metrics-prometheus</artifactId>
</dependency>content_copy
Using Prometheus metrics in your application
To enable Prometheus metrics, register it with the web server.
import io.helidon.metrics.prometheus.PrometheusSupport;
//...
Routing.builder()
.register(PrometheusSupport.create())
.register("/myapp", new MyService())
.build();content_copy
This example uses the default CollectorRegistry and exposes an endpoint /metrics. You can use fluent API builder obtained by PrometheusSupport.builder() to configure a different CollectorRegistry or a different path.