Micrometer

Starting with Spring Boot 2.0, Spring Framework changed the default library used for metrics gathering. This was previously Dropwizard Metrics (https://metrics.dropwizard.io), but now it is a brand new library called Micrometer (https://micrometer.io). Micrometer is a standalone library with a minimal list of dependencies. This is developed as a separate project, but it targets Spring Framework as its primary consumer. The library provides a facade over clients for the most popular monitoring systems. Micrometer gives a vendor-neutral monitoring API in the same way that SLF4J gives such an API for logging. At the moment, Micrometer integrates well with Prometheus, Influx, Netflix Atlas, and a dozen other monitoring systems. It also has an embedded in-memory metrics store that allows using the library even without an external monitoring system.

Micrometer is designed to support dimensional metrics where each metric besides a name may contain tags in key/value. Such an approach makes it possible to overview aggregated values and also to drill-down with tags when required. When the target monitoring system does not support dimensional metrics, the library flattens associated tags and adds them to the name.

To learn more about Micrometer design, its API, and supported monitoring systems, please refer to the project site at https://micrometer.io.

A Spring Boot actuator uses Micrometer to report application metrics via the /actuator/metrics endpoint. With an actuator module, we get a bean of the  MeterRegistry type auto-configured by default. This is a Micrometer interface that guards the client code against the details of how and where all metrics are stored. Each supported monitoring backend has a dedicated implementation of the MeterRegistry interface, so for Prometheus support, an application has to instantiate the PrometheusMeterRegistry class. Of course, Micrometer provides a CompositeMeterRegistry to report metrics to more than one registry at once. Furthermore, a MeterRegistry interface is an entry point that allows adding custom application metrics from the user code.

There are different types of metrics (such as Timer, Counter, Gauge, DistributionSummary, LongTaskTimerTimeGaugeFunctionCounter, FunctionTimer) and all of these extend the Meter interface. Every metric type has a versatile API and makes it possible to configure monitoring behavior in the desired way.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.17.27