I have tried the new way of customizing the health Actuator in Spring Boot 2.0.0.M5, as described here: https://spring.io/blog/2017/08/22/introducing-actuator-endpoints-in-spring-boot-2-0:
@Endpoint(id = "health")
public class HealthEndpoint {
@ReadOperation
public Health health() {
return new Health.Builder()
.up()
.withDetail("MyStatus", "is happy")
.build();
}
}
However, when I run HTTP GET to localhost:port/application/health
, I still get the standard default health info. My code is completely ignored.
When I use the "traditional way" of customizing the health info via implementation of HealthIndicator
, it works as expected, the health information is decorated with the given details:
@Component
public class MyHealthIndicator implements HealthIndicator {
@Override
public Health health() {
return new Health.Builder()
.up()
.withDetail("MyStatus 1.1", "is happy")
.withDetail("MyStatus 1.2", "is also happy")
.build();
}
}
QUESTION: What more shall I configure and/or implement to make the @Endpoint(id = "health")
solution working?
My intention is not to create a custom actuator myhealth
, but to customize the existing health
actuator. Based on the documentation I expect to reach the same result as by implementing HealthIndicator. Am I wrong in that assumption?
The Maven configuration pom.xml
contains:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M5</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
The Spring Boot configuration application.properties
contains:
endpoints.health.enabled=true
endpoints.autoconfig.enabled=true
endpoints.autoconfig.web.enabled=true