Kafka Streams Monitoring and Metrics with Spring Boot

Learn how to collect and expose metrics in Kafka Streams applications using Spring Boot Actuator and the micrometer project.

Monitoring is an important aspect of every application in production. How does our app perform? Does it contain bottlenecks? Which classes and flows should be optimized? Without monitoring and metrics, it is hard to answer these questions.

Luckily, Spring Boot provides built-in and easy-to-use monitoring and metrics libraries. Micrometer is an open-source set of libraries used by Spring Boot to collect metrics, and Spring Boot Actuator is a Spring project that facilitates exposing the collected metrics using a REST API. Using these, we can collect and expose Kafka Streams’ metrics and define our own custom metrics.

Actuator dependency and configuration

Below is a fully functional Spring Boot Kafka Streams application. We will add the actuator dependency and some configuration properties to enable it:

Get hands-on with 1400+ tech skills courses.