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
- Host: GitHub
- URL: https://github.com/ahus1/prometheusvertxminimal
- Owner: ahus1
- License: apache-2.0
- Created: 2017-05-14T20:35:51.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-02-12T20:14:49.000Z (about 4 years ago)
- Last Synced: 2025-06-07T10:53:25.941Z (10 months ago)
- Topics: prometheus, vertx
- Language: Java
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
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));
----