Introduction
Micrometer is the metrics collection facade for JVM-based applications, often called the SLF4J of metrics. It provides a vendor-neutral API for recording application metrics — counters, gauges, timers, distribution summaries, and histograms — and ships them to the monitoring backend of your choice. Micrometer is the default metrics library in Spring Boot Actuator.
What Micrometer Does
- Provides a unified API for recording counters, gauges, timers, and distribution summaries in JVM applications
- Exports metrics to 15+ monitoring systems including Prometheus, Datadog, New Relic, InfluxDB, and CloudWatch
- Tracks JVM internals automatically: memory usage, garbage collection, thread pools, and class loading
- Records HTTP server and client metrics with automatic dimensional tagging for Spring Boot applications
- Supports histogram and percentile computation for latency distribution analysis
Architecture Overview
Micrometer defines a MeterRegistry abstraction that each monitoring backend implements. Application code records metrics through Meter objects (Counter, Timer, Gauge, DistributionSummary) bound to a registry. Tags (key-value pairs) add dimensions to every metric for filtering and grouping. Composite registries allow publishing the same metrics to multiple backends simultaneously. In Spring Boot, auto-configuration creates the appropriate registry bean and binds default JVM and HTTP metrics automatically.
Self-Hosting & Configuration
- Add the core
micrometer-coredependency plus the registry module for your monitoring backend - In Spring Boot, add
micrometer-registry-prometheusand metrics are automatically exposed at/actuator/prometheus - Configure common tags in
application.propertiesto add environment, service name, or region labels to all metrics - Customize metric names and tags using
MeterFilterbeans for renaming, dropping, or transforming meters - Set histogram bucket boundaries and percentile targets for timer and distribution summary metrics
Key Features
- Vendor-neutral API — switch monitoring backends by changing a dependency, not application code
- Dimensional metrics with tags enable flexible filtering, grouping, and aggregation in dashboards
- Automatic instrumentation for Spring MVC, WebFlux, JDBC, Kafka, and cache libraries
- Rate aggregation and histogram support built into timers and distribution summaries
- Active maintenance by the Spring team with releases aligned to Spring Boot versions
Comparison with Similar Tools
- Prometheus Java Client — Direct Prometheus instrumentation without the abstraction layer; lower overhead but locks you into one backend
- Dropwizard Metrics — Predecessor metrics library with codahale-style naming; lacks dimensional tagging and multi-backend support
- OpenTelemetry Java SDK — Broader observability scope covering traces, metrics, and logs, but heavier and more complex for metrics-only use cases
- StatsD — UDP-based metrics aggregation protocol; simple but requires a separate aggregation daemon and lacks rich type support
FAQ
Q: Is Micrometer only for Spring Boot? A: No. Micrometer is a standalone library that works with any JVM application. Spring Boot provides auto-configuration, but you can create and manage MeterRegistries manually in any Java, Kotlin, or Groovy project.
Q: Can I send metrics to multiple monitoring systems? A: Yes. Use a CompositeMeterRegistry to publish the same metrics to Prometheus, Datadog, and any other supported backend simultaneously.
Q: How does Micrometer relate to OpenTelemetry? A: Micrometer focuses on metrics with a clean, type-safe API. Micrometer Tracing (formerly Spring Cloud Sleuth) bridges to OpenTelemetry for distributed tracing. You can use both together.
Q: Does Micrometer add significant overhead? A: Micrometer is designed for production use with minimal overhead. Meter lookups are cached, and recording operations are lock-free where possible.