Metrics and Dashboards with Micrometer and Prometheus
Expose application metrics with Micrometer, scrape them with Prometheus, and visualize trends in Grafana for full observability.
Metrics and Dashboards with Micrometer and Prometheus is a free Spring Boot 4 Complete Guide lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Spring Boot 4 Complete Guide learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Beyond Logs and Traces
Logs tell you what happened and traces show request paths, but metrics reveal trends over time: request rates, error percentages, memory use. They complete the observability picture.
What Is Micrometer?
Micrometer is a metrics facade, like SLF4J but for metrics. You instrument once and export to many backends such as Prometheus or Datadog.
Wiring in Prometheus
Add the Prometheus registry dependency and Actuator exposes a scrape endpoint automatically.
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>Exposing the Endpoint
Enable the Prometheus endpoint so metrics are served at /actuator/prometheus in a format Prometheus understands.
management.endpoints.web.exposure.include=health,prometheusThe Three Core Meter Types
Most metrics fall into three types.
- Counter — only goes up (requests served)
- Gauge — goes up and down (queue size)
- Timer — measures durations
Creating a Counter
Register a counter and increment it when an event occurs.
Counter c = registry.counter("orders.placed");
c.increment();Timing Code
A Timer records how long operations take, giving you latency percentiles.
Timer t = registry.timer("checkout.duration");
t.record(() -> processCheckout());Tags for Dimensionality
Add tags (labels) to slice metrics by endpoint, status, or region. Avoid high-cardinality tags like user IDs, which explode storage.
registry.counter("http.requests", "status", "200").increment();How Prometheus Scrapes
Prometheus periodically pulls the /actuator/prometheus endpoint and stores time-series data, which you can then query with PromQL.
Visualizing with Grafana
Grafana connects to Prometheus as a data source and renders dashboards. Spring Boot has ready-made dashboards for JVM and HTTP metrics.
Alerting on Metrics
Define alert rules, for example error rate above 5 percent, so the team is notified before users complain. Metrics turn into proactive operations.
Quick Check
Test your understanding of metrics and observability.
Recap
You exposed metrics via Micrometer and the Prometheus Actuator endpoint, learned counters, gauges, and timers, used tags wisely, and visualized and alerted with Prometheus and Grafana.
Frequently asked questions
Is the “Metrics and Dashboards with Micrometer and Prometheus” lesson free?
Yes — the full text of “Metrics and Dashboards with Micrometer and Prometheus” is free to read here on the web, and the Spring Boot 4 Complete Guide course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Spring Boot 4 Complete Guide course, upgrade to CoddyKit PRO.
What will I learn in “Metrics and Dashboards with Micrometer and Prometheus”?
Expose application metrics with Micrometer, scrape them with Prometheus, and visualize trends in Grafana for full observability. You practise Spring Boot 4 Complete Guide with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Spring Boot 4 Complete Guide?
No prior experience is required. Spring Boot 4 Complete Guide on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Metrics and Dashboards with Micrometer and Prometheus” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Spring Boot 4 Complete Guide lesson?
Yes. Every Spring Boot 4 Complete Guide lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Kubernetes Orchestration Basics
- Distributed Tracing with Sleuth & Zipkin
- Health Checks & Resilience Patterns
- Metrics and Dashboards with Micrometer and Prometheus