client_java v1.x).
See the overview for the general approach.
1. Add the Prometheus client dependency
Add these dependencies to yourpom.xml (Maven):
build.gradle):
2. Register custom metrics and expose /metrics
Register default JVM metrics, define your own custom counters/gauges, and start an HTTP server that exposes them on
/metrics:
9090 that responds to GET /metrics in Prometheus exposition format —
including JVM metrics like jvm_memory_used_bytes, jvm_gc_pause_seconds, jvm_threads_live_threads, plus your
custom emails_sent_total.
3. Declare the metrics endpoint in ops.json
http://<your-service>:9090/metrics every 15 seconds and make every metric — JVM and custom
— available in Grafana.
4. Visualize JVM metrics with a community dashboard
Instead of building JVM dashboards from scratch, import a battle-tested community dashboard from grafana.com/grafana/dashboards.| Dashboard | ID | Notes |
|---|---|---|
| JVM (Micrometer) | 4701 | Most popular JVM dashboard. Built for Micrometer but most panels work with client_java v1.x since metric names like jvm_memory_used_bytes and jvm_threads_live_threads overlap. |
| JVM (Micrometer) — alternative | 8898 | Alternative JVM dashboard, also Micrometer-based. |
| JVM SpringBoot3 | 22108 | For Spring Boot 3.x apps using Actuator + Micrometer. |
emails_sent_total, etc.) can be charted alongside in the same or a separate dashboard.