Spring Boot Kafka health indicator: write a custom HealthIndicator
Codemia Knowledge Hub ·
Spring Boot Actuator does not auto-configure a Kafka health indicator. One was added and then reverted (spring-boot issue #12225), and the Spring Boot team declined to bring it back because a client-side check cannot see broker and in-sync replica settings and risks reporting an inaccurate status. To show Kafka in /actuator/health, write your own HealthIndicator bean that checks the brokers you configure.
Why check Kafka's health
Apache Kafka is an open-source stream-processing platform, developed at LinkedIn and donated to the Apache Software Foundation, built for high-throughput, low-latency real-time data feeds. If your application depends on it for messaging or stream processing, Kafka failures can cause data loss, delayed processing or unavailable services. Actuator health indicators already report on things like database connections and disk space, and a Kafka check helps you spot problems early, often before users notice.
Dependencies and configuration
- Add the Actuator starter and Spring for Apache Kafka to your
pom.xmlorbuild.gradle. - Configure the Kafka connection details in
application.propertiesorapplication.yml, and enable health details.
Maven example:
application.yml example:
What a custom Kafka indicator should do
A custom indicator typically tries to connect to the brokers in spring.kafka.bootstrap-servers. If the connection succeeds, it reports UP. If it fails, it reports DOWN with details of the exception. Spring Boot picks up any HealthIndicator bean and includes it in the health endpoint. Keep the check simple and be aware of its limits: a successful connection does not prove that topics, replicas or transactions are healthy.
A minimal version uses the auto-configured KafkaAdmin to ask the cluster for its ID:
Spring Boot derives the name from the bean, so this shows up as kafka in /actuator/health.
| Feature | Description |
| Dependency | Requires spring-boot-starter-actuator and spring-kafka. |
| Properties Configuration | Must configure Kafka brokers in application.yml or application.properties. |
| Health Status | A custom indicator returns UP if the broker connection succeeds, otherwise DOWN. |
| Endpoint Usage | Accessible via /actuator/health when Spring Boot Actuator’s web exposure includes 'health'. |
Health is not performance
A connection check says nothing about latency or throughput. For full monitoring, add metrics and logging that show how Kafka performs inside your application, which matters most in event-driven systems that rely heavily on asynchronous processing.
Related reading
- Spring Boot Kafka Listener vs Consumer
- Spring Boot Kafka Startup error Connection to node -1 could not be established. Broker may not be available.
- Spring Boot Kafka Unable to start consumer due to NoSuchBeanDefinitionException
- spring boot rabbitmq MappingJackson2MessageConverter custom object conversion
- Spring Boot, logback and logging.config property
- Spring Boot logging pattern
- Spring Boot Load Value from YAML file
- Spring Boot logging with Lombok
System design interview problems on this topic
- Design a Distributed Messaging System: solution and walkthrough
- Design a Log Collection and Analysis System: solution and walkthrough
- Design an Ad Click Aggregation System: solution and walkthrough
- Design a Webhook Notification Service: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.