Micrometer: A dimensional-first metrics collector for Spring Boot 2
Looking for a vendor-neutral facade for application metrics? As a part of the all-new Spring Boot 2, Micrometer is the instrumentation library powering the delivery of application metrics from Spring.
Spring Boot 2 arrived earlier this month and we’re still unpacking all the cool goodies inside. Today, we’re taking a closer look at Micrometer, a metrics instrumentation library. Thanks to Micrometer’s dimensional-first metrics collection façade, developers can time, count, and gauge their code with a vendor neutral API.
When we talk about metrics, we mean the class of information that allows developers to reason about the performance of a system in the aggregate. So, if we want to look at information about the different components of a single app or instances in a cluster. That kind of thing. Micrometer provides this kind of information in aggregate.
Micrometer is a step up from the precious meter collection library for Spring Boot 1.0. It brings a richer output from the standard counters and gauges. It’s designed to have a light footprint and add little to no overhead to your metrics collection activity without vendor lock-in.
Okay, first off, we need to make one thing clear. Micrometer is not a distributed tracing system. Nor is it an event logger. It is a metrics instrumentation library. If you want to see some of the differences between these types of systems, there’s a good explainer here.
Instead, Micrometer provides vendor neutral interfaces for times, gauges, counters, distribution summaries, and long task times. These are paired with a dimensional data model and a dimensional monitoring system that allows developers to access a particular metric with speed and efficiency. However, even though it does focus on the dimensional aspect, Micrometer does map to hierarchical names to serve older monitoring solutions as well.
Spring Boot chose to integrate Micrometer in order to allow developers more choices, now and in the future. Since Micrometer is vendor-neutral, developers can pick and choose which systems they want to use today; switching in the future shouldn’t require a rewrite of custom metric implementation either. And now, Micrometer is ported back to Boot 1.x for Spring with just an additional library dependency.
What kind of metrics are we talking about here?
Spring Boot 2 already offers a number of autoconfigured metrics. Some of these were already included in Spring Boot 1.x, but they have been enriched with greated detail and tags in the latest version. Here are some of the metrics it collected:
- CPU usage
- Spring MVC and WebFlux request latencies
- RestTemplate latencies
- Cache utilization
- File descriptor usage
- Logback: record the number of events logged to Logback at each level
- Uptime: report a gauge for uptime and a fixed gauge representing the application’s absolute start time
In particular, Micrometer supports a lot of monitoring systems, with more on the way. Dimensional monitoring systems include Atlas, Datadog, Datadog StatsD, Influx, Prometheus, SignalFX, Telegraf StatsD, and Wavefront. It also supports hierarchical monitoring systems like Graphite, Ganglia, JMX, and Etsy StatsD.
Learn more about Micrometer
This helpful metrics instrumentation library for JVM-based applications is included in Spring Boot 2. However, more information can be found at GitHub or on the Micrometer website. Feel free to ask questions, make suggestions, or point out problems to the Micrometer team on slack at at slack.micrometer.io, on Twitter @micrometerio, and on Github.