olahell olahell - 1 month ago 18
Java Question

spring-boot health not showing details (withDetail info)

I have written a class implementing HealthIndicator, overriding the health-method. I return

Health.down().withDetail("SupportServiceStatus", "UP").build();


This should make my
health
-endpoint return:

{
"status":"UP",
"applicationHealth": {
"status":"UP"
}
}


Instead it just returns (health, without details):

{
"status":"UP",
}


Javacode (somewhat simplified):

@Component
public class ApplicationHealth implements HealthIndicator {

@Override
public Health health() {
return check();
}

private Health check() {
return Health.up().withDetail("SupportServiceStatus", supportServiceStatusCode).build();
}

}

Answer

According to spring-boot docs:

. . . by default, only the health status is exposed over an unauthenticated HTTP connection. If you are happy for complete health information to always be exposed you can set endpoints.health.sensitive to false.

Solution is to set endpoints.health.sensitive to false in application.properties.

application.properties

endpoints.health.sensitive=false