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.
To import: in Grafana, go to Dashboards → New → Import, enter the dashboard ID, and select your LocalOps Prometheus
data source. You’ll instantly see heap/non-heap memory, GC activity, thread counts, classloader stats, and more. Your
custom application metrics (
emails_sent_total, etc.) can be charted alongside in the same or a separate dashboard.