I am running Spring Boot v1.5.2.RELEASE.
When I do curl localhost:8080/health i get:
{
"status": "UP",
"test": {
"status": "UNKNOWN",
"hello": "test123"
},
"diskSpace": {
"status": "UP",
"total": 999234207744,
"free": 806942392320,
"threshold": 10485760
},
"db": {
"status": "UP",
"database": "MySQL",
"hello": 1
}
}
Here is my code below for TestHealthIndicator.java:
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health.Builder;
import org.springframework.stereotype.Component;
@Component
public class TestHealthIndicator extends AbstractHealthIndicator {
@Override
protected void doHealthCheck(Builder builder) throws Exception {
builder.withDetail("hello", "test123");
}
}
I also have this in my pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Question: How do I get /health to return something like below without the db and diskspace information?
{
"status": "UP",
"test": {
"status": "UNKNOWN",
"hello": "test123"
}
}
According to the docs you can disable all of custom HealthIndicator beans with the following property:
management.health.defaults.enabled=false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With