I am trying to add custom functionality to health check endpoint. Created class according to this post :
@Component
public class CustomHealthCheck extends AbstractHealthIndicator {
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
boolean someValue = true;
if (someValue) {
builder.withDetail("MyCustomField", "MyValue");
builder.up();
} else {
builder.down();
}
}
}
But when accessing to health endpoint via postman or via browser (/actuator/health) I got response
{
"status": "UP"
}
i.e. custom field was not added to the response I also see in debugger , that doHealthCheck method of CustomHealthCheck was executed
Here are relevant definitions from application.properties :
management.endpoints.enabled-by-default=true
management.endpoint.health.enabled=true
management.endpoint.info.enabled=true
management.endpoints.web.exposure.include=health,info
Is there something missing in the code or definitions ? Thanks in advance