Spring boot kafka health indicator example For example, if you have spring-boot-starter-data-mongodb in your project, Spring Boot will automatically include a MongoHealthIndicator. Jul 23, 2025 · In this article, you’ll learn how to: Implement liveness and readiness probes in Spring Boot. Spring Boot Actuator provides production-ready features that help you monitor and manage your application. Spring Kafka brings the simple and typical Spring template programming model with a KafkaTemplate and Message-driven POJOs via @KafkaListener annotation. Ensuring the health of Kafka clusters is crucial for the reliability and performance of these systems. Spring Cloud Stream Kafka Streams Binder provides a health indicator to check the state of the underlying streams threads. yml like that: management: Aug 17, 2018 · In previous versions of Spring-Boot there was an inbuild health indicator for Kafka, however somewhere along the way it was lost. If your application can continue to function without Kafka then you do not want your app to be considered down if Kafka is down. Spring Boot comes with the Actuator module which provides the health status and integrates with Micrometer to emit metrics. Reactor Kafka binder provides a HealthIndicator implementation that will be used when invoking the Spring Boot Actuator health endpoint. In this example, we try to override the binder provided Kafka HealthIndicator by specifically checking first for cluster connectivity and then followed by topic-related issues. 3, LivenessStateHealthIndicator and ReadinessStateHealthIndicator classes will expose the liveness and readiness state of the application. They are auto-configured by default: CassandraHealthIndicator Config Server comes with a Health Indicator that checks whether the configured EnvironmentRepository is working. Oct 14, 2025 · In modern distributed systems, Apache Kafka has become a popular choice for building real - time data pipelines and streaming applications. Among those approaches, the HealthContributor and HealthIndicator APIs are two notable ones. May 27, 2025 · Health Indicators Spring Boot comes with a set of "Health Indicators" that are automatically configured if the corresponding technology is detected on your classpath. Sep 4, 2025 · Discover how to build a custom Kafka health indicator in Spring Boot to strengthen microservice resilience and enhance Kubernetes liveness/readiness probe accuracy. Also I'd like to check ability of application to consume and produce messages. x, the metrics support is provided through a custom Micrometer metrics implementation by the binder. In this tutorial, we’ll cover Spring support for Kafka and its abstraction level over native Kafka Java client APIs. show-details with the value ALWAYS in your application. By default, you will only receive the top level application status when you hit the above endpoint. By default, it asks the EnvironmentRepository for an application named app, the default profile, and the default label provided by the EnvironmentRepository implementation. Spring Cloud Stream defines a property management. I found some solutions (Spring Boot: Kafka health indicator) where Kafka was checked through KafkaAdmin (via describeCluster()). In this article, we will explore how to create custom health checks in Spring Boot, with detailed coding examples. 2. In order to receive the full details from the binder specific health indicators, you need to include the property management. I added actuator health check endpoint. endpoint. Sep 19, 2019 · I have a spring boot app where I use apache kafka-streams. Why Self-Healing Matters Failures are inevitable in distributed systems. AbstractHealthIndicator org. 6) application that both consumes and produces messages to a (organization wide) common kafka instance. Understanding health indicators allows developers to implement custom checks Sep 4, 2025 · Discover how to build a custom Kafka health indicator in Spring Boot to strengthen microservice resilience and enhance Kubernetes liveness/readiness probe accuracy. This blog post will explore the core concepts, typical usage, common practices, and best practices related to Actuator Kafka Health. Jun 19, 2020 · 3. Liveness and Readiness in Actuator As of Spring Boot 2. Dec 26, 2018 · Spring Boot provides the following HealthIndicator implementations out-of-the-box. When Spring Boot actuator dependency is on the classpath, the Reactor Kafka binder can be enabled with a binder health indicator. lang. springframework. This guide describes the Apache Kafka implementation of the Spring Cloud Stream Binder. Kafka configuration is controlled by external configuration properties in spring. In addition, this guide explains the Kafka Streams binding capabilities of Spring Cloud Stream. May 7, 2025 · Explore the monitoring capabilities provided by Spring Kafka using Micrometer and Spring Boot Actuator. boot. KafkaHealthIndicator All Implemented Interfaces: HealthIndicator public class KafkaHealthIndicator extends AbstractHealthIndicator Jul 21, 2023 · This article explores monitoring Spring Boot applications' health using custom health indicators, offering insights and encouraging discussions for effective solutions. Take a look at the native metrics exposed by Apache Kafka for both producers and consumers, which offer valuable insights into performance, throughput, errors, and latency and those augmented by Spring. This could be costly! Sep 4, 2023 · I need to add Kafka health checks in my spring boot app. diskSpace is one of predefined health indicators in spring boot comming from org. Implementation To retrieve the health of the application, make a GET request to /actuator/health, as shown in the following curl-based example: Sep 22, 2020 · Monitoring and observability are essential in distributed environments. Sep 22, 2020 · Monitoring and observability are essential in distributed environments. Here is the pseudo-code for writing a custom Kafka binder HealthIndicator. Spring Boot Actuator provides a convenient way to monitor the health of various components, including Kafka. This guide covers the rationale, implementation, configuration, and best practices for production-grade health checks. actuate. e. I configured it in the application. I don't use spring cloud streams. if it is currently UP or DOWN In this tutorial, we will explore the concept of health indicators in Spring Boot, a powerful framework for creating Java applications. Sep 19, 2024 · Learn how to implement custom health indicators in Spring Boot Actuator to enhance application monitoring and ensure optimal performance. It contains information about its design, usage, and configuration options, as well as information on how the Stream Cloud Stream concepts map onto Apache Kafka specific constructs. 1. For example, you might declare the following section in application. Mar 25, 2017 · Apache Kafka is a distributed and fault-tolerant stream processing system. *. Jan 8, 2024 · Spring Boot provides a few different ways to inspect the status and health of a running application and its components. Actuator endpoints for Kafka This is a simple project built on top of Spring Boot's Actuator and Spring Boot for Apache Kafka project that aims to provide a simple way of getting health-check functionality for your Kafka Spring Boot application. Also Spring Boot doesn’t provide any kafka health indicator out of the box as of today, so in this scenario we need to go for custom health indicator. Learn how to implement a Kafka health indicator in your Spring Boot application to monitor Kafka health effectively. kafka. Configure Kubernetes for auto-restart and traffic control. Nov 17, 2020 · First consider when and why you should do a check for the health of the Kafka brokers. Sep 24, 2025 · This article shows you how to use Azure Event Hubs in Java applications built with Spring framework. binders. May 24, 2023 · There is no way to provide a health indicator that will reliably satisfy all possible conditions; for example, if transactions are being used and there are not enough in-sync replicas running for the transaction log, there is no way to determine that situation. I am trying to implement health checks for this kafka broker in my application using spring actuator and I am facing a bunch of issues related to performance and logging. Object org. It was inspired by existent functionalities present in the Spring Cloud Stream project. Dec 11, 2019 · 12 I have a spring boot (2. Is it correct to check health/state of Kafka components with health topic? Aug 15, 2024 · This is where custom health checks come into play. Class KafkaHealthIndicator java. When we deploy our application to Kubernetes, Spring Boot will automatically register these health indicators. 2. Health indicators are crucial for monitoring the state of an application, enabling developers and operations teams to quickly assess system health and respond to issues as they arise. May 14, 2019 · For example one scenario that can happen is that your app loses connectivity to Kafka - your health check turns RED - and then elastic beanstalks begins a process of killing and re-starting your instances (which will happen continually until your Kafka instances are available again). DiskSpaceHealthIndicator. Apr 6, 2022 · Monitoring Kafka Applications — Implementing Healthchecks and Tracking Lag For KafkaConsumer, Streams, Spring-Kafka, Kafka-Connect Microservices often use a model of sending or replying to … Feb 9, 2022 · By implementing a Kafka health indicator and combining it with periodically k8s probes access, to automatically trigger a message sending, thus it would refresh the idle connection periodically. Oct 14, 2025 · Spring Boot Actuator provides a convenient way to monitor the health of various components, including Kafka. enabled to enable the health indicator. This blog post will explore the core Jun 16, 2024 · Spring Boot provides health indicators to monitor application health and database health with the help of Spring Boot Actuator. Create custom health indicators using Spring Actuator. What Is a Listener Container in Spring for . health. properties: You can use Spring Boot actuator health endpoint to access the health indicator - /actuator/health. Refs: #11515 KafkaHealthIndicator Please add the HealthIndicator fo Jun 8, 2024 · Spring Boot provides Health Indicators to monitor application health and database health with the help of Spring Boot Actuator. Let’s get started. Mar 10, 2025 · Learn how to create custom health checks and metrics endpoints in Spring Boot Actuator, secure them with Spring Security, and more! Accessing Kafka Streams Metrics Spring Cloud Stream Kafka Streams binder provides Kafka Streams metrics which can be exported through a Micrometer MeterRegistry. 1. Dec 22, 2017 · In your example myHealthCheck and diskSpace are beans in spring context that were called when you hit /health. For this reason, Boot decided not to provide one and users can provide their own instead, for their specific situation. For Spring Boot version 2. Debug and troubleshoot health check issues. Spring Boot Actuator comes with various Health Indicators for most (Just Now) Implementing a Kafka health indicator in a Spring Boot application enables you to monitor the connection between your app and Kafka, ensuring reliable message delivery and system … Jun 6, 2025 · Learn how to build and register custom health indicators in Spring Boot using Actuator, with code examples and support for readiness and liveness probes. This health indicator provides information about the status of the binder based application, i. Apr 1, 2021 · How Kafka consumers and Kafka Streams status and details can be used for monitoring in a Spring Boot application using Actuator health endpoint. 94 ptn9x5 gg jwubyg5t sb8b 37z8a xkx omr1d3 2ijpm9 hkzlzbmba