Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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();
  }

}
like image 776
olahell Avatar asked Oct 06 '15 13:10

olahell


People also ask

What is health indicator in spring boot?

By default, Spring Boot defines four different values as the health Status: UP — The component or subsystem is working as expected. DOWN — The component is not working. OUT_OF_SERVICE — The component is out of service temporarily. UNKNOWN — The component state is unknown.

How do I turn on actuators in spring boot?

To enable Spring Boot actuator endpoints to your Spring Boot application, we need to add the Spring Boot Starter actuator dependency in our build configuration file. Maven users can add the below dependency in your pom. xml file. Gradle users can add the below dependency in your build.


2 Answers

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

For >1.5.1 application.properties

management.security.enabled=false 

At Spring Boot 2.0.0.RELEASE (thx @rvit34 and @nisarg-panchal):

management:
  endpoint:
    health:
      show-details: "ALWAYS"
  endpoints:
    web:
      exposure:
        include: "*"

management.endpoints.web.exposure.include=* exposes all endpoints, if that is what you want.

Current documentation can be found here: https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html

like image 177
olahell Avatar answered Oct 17 '22 14:10

olahell


At Spring Boot 2.0.0.RELEASE:

management:
   endpoint:
      health:
        show-details: "ALWAYS"
like image 16
rvit34 Avatar answered Oct 17 '22 15:10

rvit34