Spring Boot 2.X has significantly changed actuator. A new, better mechanism to extend existing endpoints is enabled via @EndpointWebExtension
.
That being said, health endpoint is a bit trickier to extend because one extension for it is provided out of the box by actuator itself. Without manipulating beans initialization process, your application will not be able to start since it will see 2 extensions and will not understand which one to choose.
An easier way would be to use info instead and extend it:
@Component
@EndpointWebExtension(endpoint = InfoEndpoint.class)
public class InfoWebEndpointExtension {
@Value("${info.build.version}")
private String versionNumber;
@Value("${git.commit.id}")
private String gitCommit;
@Value("${info.build.name}")
private String applicationName;
...
@ReadOperation
public WebEndpointResponse<Map> info() {
Don't forget that you can also re-map URLs. In my case I prefer /status to /health and don't want /actuator/ in the path:
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.info=status
Another reason why I prefer /info is because I don't get this nested structure, which is default for /health:
{
"status": {
"status": "ON",