Clint Checketts, core committer of Micrometer Project, recently spoke at SpringOne Platform 2019 Conference about Micrometer monitoring and alerting framework. Micrometer provides a simple SDK facade over instrumentation clients for different monitoring systems that allows developers to instrument JVM-based applications. Not only can it be used for recording metrics, but it can also provide a wide range of observability features when used alongside other tools like Prometheus and Grafana.
Checketts discussed the importance of dimensional metrics in the overall monitoring of systems. Similar to other products like Google Prometheus and Netflix Atlas, Micrometer provides the support for managing dimensional time-series based metrics data.
He talked about the difference between dimensional metrics and hierarchical metrics. Dimensional metrics record data differently. Rather than using a hierarchical key/value data structure, they are instead "tagged", with each metric consisting of a name and a list of multiple tagged statistics. This allows for better querying flexibility and extensibility. It's not just about monitoring for errors, but actually understanding the overall health of the system.
The modern definition of observability is based on three pillars:
- Logging: Detailed information about individual actions. Libraries include SLF4J, Log4J, Logback, and JUL.
- Metrics: Aggregate information about application features. Libraries include Micrometer, Prometheus, and Drop Wizard Metrics.
- Tracing: Sampled information across multiple services. Zipkin library falls into this category.
Checketts discussed the core logging features, and explored how Micrometer compares to traditional logging. It supports common logging with destinations such as Elasticsearch. It can also be used for adding cross-cutting metdadata like nested diagnostic contexts (NDC) to the log messages.
Micrometer terminology includes the following components: Meter: what is measured, e.g. counters, timers, and gauges; MeterRegistry: a Meter store abstraction; Tag: a Meter dimension; and Metric: an individual measurement.
Checketts showed how to use the monitoring framework in different applications, and gave the examples of Micrometer using Docker and Kotlin using SimpleMeterRegistry and CompositeMeterRegistry classes.
He discussed the Micrometer integration in Spring-based applications. The support is built into Spring, and the class just needs to be autowired. Another demo showed how to set up a Spring application with Micrometer and enable the Prometheus Actuator. Also, the Metrics Actuator is powered by Micrometer.
Resilience4J, a fault tolerance library, includes Micrometer support, and can be used to monitor the statistics like circuit breaker state and success/failure rates. Checketts also showed how to get custom frontend metrics from an Angular application, sending metrics to a Micrometer backend every five seconds.
You can download the sample code shown in the presentation from the GitHub project.