Skip to content

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:

Health endpoint 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:

pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

I also had database and Redis dependencies:

pom.xml
<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:

application.yml
management:
endpoint:
health:
show-details: always

Then I called the health endpoint again:

Health endpoint request
curl http://localhost:8080/actuator/health

The response showed all active health indicators:

Health response with details
{
"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

IndicatorPurposeActivates When
DataSourceDatabase connectivityJDBC DataSource bean present
DiskSpaceAvailable disk spaceAlways active
RedisRedis connectivityRedis client on classpath
MongoDBMongoDB connectivityMongoDB client on classpath
ElasticsearchElasticsearch clusterElasticsearch client present
Neo4jNeo4j databaseNeo4j client on classpath
HazelcastHazelcast clusterHazelcast instance present
RabbitMQRabbitMQ brokerRabbitMQ client present
JMSJMS brokerJMS client configured
LDAPLDAP serverLDAP configured
SSLCertificate validitySSL 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:

application.yml
management:
endpoint:
health:
show-details: never # default value

You have three options:

  • never - Never show details (default)
  • always - Always show details
  • when-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:

application.yml
management:
health:
mongo:
enabled: false

You can also disable all auto-configured indicators and enable only specific ones:

application.yml
management:
health:
defaults:
enabled: false
db:
enabled: true
diskspace:
enabled: true

For the disk space indicator, you can configure the threshold:

application.yml
management:
health:
diskspace:
enabled: true
threshold: 100MB # minimum free space required

Checking Active Health Indicators Programmatically

If you want to see what health indicators are registered in your application, you can inject the HealthContributorRegistry:

HealthController.java
@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:

List of active indicators
["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:

RedisHealthContributorAutoConfiguration.java
@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:

  1. Spring Boot auto-configures health indicators based on classpath dependencies
  2. By default, health details are hidden for security reasons
  3. Use management.endpoint.health.show-details to control visibility
  4. Disable specific indicators with management.health.{name}.enabled=false
  5. 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:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments