An open API service indexing awesome lists of open source software.

https://github.com/ahus1/prometheusvertxminimal

Minimal example on how to use Prometheus Monitoring for Vert.x applications
https://github.com/ahus1/prometheusvertxminimal

prometheus vertx

Last synced: 10 months ago
JSON representation

Minimal example on how to use Prometheus Monitoring for Vert.x applications

Awesome Lists containing this project

README

          

= Minimal example on how to setup Vert.x with Prometheus

== What to expect

Run a Vert.x application and read metrics from JVM and Vert.x using a Prometheus endpoint.

== Motivation

There used to be no minimal example as part of the Prometheus' Java Client available.

== How to Run

To run with maven

mvn compile exec:java

Open http://localhost:8081 to access the metrics.

New metrics abouts Vert.x will appear as they are used for the the first time.
Example: the metrics about the event bus will appear once the first event is sent to the event bus.

More information: https://vertx.io/docs/vertx-micrometer-metrics/java/

== Key bits and pieces

1. Start Vert.x with Micrometer Metrics
+
.VertxApplication.java
[source,indent=0]
----
vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(
new MicrometerMetricsOptions()
.setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true))
.setEnabled(true)
));
----

2. Expose additional metrics (i.e. JVM metrics) to Prometheus
+
.VerticleWeb.java
[source,indent=0]
----
CollectorRegistry registry =
((PrometheusMeterRegistry) BackendRegistries.getDefaultNow()).getPrometheusRegistry();
(new StandardExports()).register(registry);
(new MemoryPoolsExports()).register(registry);
/* ... */
----

3. Expose Prometheus Metrics via HTTP
+
.VerticleWeb.java
[source,indent=0]
----
// map /metrics to prometheus
router.route("/metrics").getDelegate().handler(new MetricsHandler(registry));
----