What Auto-Configured Health Indicators Does Spring Boot Actuator Provide?
Problem
When I deployed my Spring Boot application to Kubernetes, I wanted to check the health endpoint. I called /actuator/health and got this response:
{ "status": "UP"}But I expected more details. I knew my app connected to a PostgreSQL database and Redis, but the health endpoint didn’t show their status. I was confused because I thought Spring Boot would automatically check those connections.
Environment
- Spring Boot 3.2.0
- Java 21
- PostgreSQL 15
- Redis 7.0
- Maven 3.9.0
What happened?
I was setting up health monitoring for my microservices. I added the Actuator dependency to my project:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId></dependency>I also had database and Redis dependencies:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId></dependency>When I checked /actuator/health, I only saw "status": "UP" without any component details. I thought Spring Boot would automatically show database and Redis health status.
How to solve it?
First, I tried to understand what health indicators were actually active. I enabled detailed health information:
management: endpoint: health: show-details: alwaysThen I called the health endpoint again:
curl http://localhost:8080/actuator/healthThe response showed all active health indicators:
{ "status": "UP", "components": { "db": { "status": "UP", "details": { "database": "PostgreSQL", "validationQuery": "isValid()" } }, "diskSpace": { "status": "UP", "details": { "total": 500068036608, "free": 87636123648, "threshold": 10485760 } }, "ping": { "status": "UP" }, "redis": { "status": "UP", "details": { "version": "7.0.0" } } }}The health indicators were already there. I just needed to enable the details visibility.
Understanding Auto-Configured Health Indicators
Spring Boot Actuator provides a comprehensive set of auto-configured health indicators. These indicators activate automatically based on your classpath dependencies.
Available Health Indicators
| Indicator | Purpose | Activates When |
|---|---|---|
| DataSource | Database connectivity | JDBC DataSource bean present |
| DiskSpace | Available disk space | Always active |
| Redis | Redis connectivity | Redis client on classpath |
| MongoDB | MongoDB connectivity | MongoDB client on classpath |
| Elasticsearch | Elasticsearch cluster | Elasticsearch client present |
| Neo4j | Neo4j database | Neo4j client on classpath |
| Hazelcast | Hazelcast cluster | Hazelcast instance present |
| RabbitMQ | RabbitMQ broker | RabbitMQ client present |
| JMS | JMS broker | JMS client configured |
| LDAP | LDAP server | LDAP configured |
| SSL | Certificate validity | SSL enabled |
Why Some Indicators Were Hidden
The reason I initially didn’t see details was security. By default, Spring Boot hides health details to prevent exposing sensitive infrastructure information:
management: endpoint: health: show-details: never # default valueYou have three options:
never- Never show details (default)always- Always show detailswhen-authorized- Show details only to authenticated users
Controlling Health Indicators
Sometimes you want to disable certain indicators. For example, if you have MongoDB on your classpath but don’t use it:
management: health: mongo: enabled: falseYou can also disable all auto-configured indicators and enable only specific ones:
management: health: defaults: enabled: false db: enabled: true diskspace: enabled: trueFor the disk space indicator, you can configure the threshold:
management: health: diskspace: enabled: true threshold: 100MB # minimum free space requiredChecking Active Health Indicators Programmatically
If you want to see what health indicators are registered in your application, you can inject the HealthContributorRegistry:
@RestController@RequestMapping("/api")public class HealthController {
private final HealthContributorRegistry healthRegistry;
public HealthController(HealthContributorRegistry healthRegistry) { this.healthRegistry = healthRegistry; }
@GetMapping("/health-indicators") public List<String> getHealthIndicatorNames() { List<String> names = new ArrayList<>(); healthRegistry.stream() .forEach(contributor -> names.add(contributor.getName())); return names; }}When I called this endpoint, I got:
["db", "diskSpace", "ping", "redis"]The Reason Behind Auto-Configuration
Spring Boot uses conditional bean registration to auto-configure health indicators. Each indicator has a corresponding auto-configuration class:
@ConditionalOnClass(RedisClient.class)@ConditionalOnBean(RedisConnectionFactory.class)@ConditionalOnEnabledHealthIndicator("redis")public class RedisHealthContributorAutoConfiguration {
@Bean public RedisHealthIndicator redisHealthIndicator( RedisConnectionFactory redisConnectionFactory) { return new RedisHealthIndicator(redisConnectionFactory); }}The key conditions are:
@ConditionalOnClass- The class must be on classpath@ConditionalOnBean- The bean must exist in context@ConditionalOnEnabledHealthIndicator- The property must be true
This design means you don’t need to write health check code for common infrastructure. Just add the dependency, and Spring Boot handles the rest.
Summary
In this post, I explored Spring Boot Actuator’s auto-configured health indicators. The key points are:
- Spring Boot auto-configures health indicators based on classpath dependencies
- By default, health details are hidden for security reasons
- Use
management.endpoint.health.show-detailsto control visibility - Disable specific indicators with
management.health.{name}.enabled=false - The available indicators include DataSource, DiskSpace, Redis, MongoDB, Elasticsearch, and more
Understanding these auto-configured indicators helps you leverage built-in monitoring without writing duplicate health checks. Just add the dependencies, configure visibility, and let Spring Boot handle the infrastructure health monitoring.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
- 👨💻 Spring Boot Actuator Documentation
- 👨💻 Spring Boot Health Indicators
- 👨💻 MicroProfile Health Specification
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments