Search code examples
springspring-bootspring-boot-actuatorhealth-monitoring

Spring Boot - Change the location of the /health endpoint to /ping/me


I set the endpoints.health.path property to /ping/me. But I cannot access the endpoint using http://localhost:9000/ping/me It only works with http://localhost:9000/health. What am I missing ? Here is the code in app properties file.

#Configuration for Health endpoint
endpoints.health.id=health
endpoints.health.path=/ping/me
endpoints.health.enabled=true
endpoints.health.sensitive=false

#Manage endpoints
management.port=9000
management.health.diskspace.enabled=false

The response I get is :

{
"timestamp" : 1455736069839,
"status" : 404,
"error" : "Not Found",
"message" : "Not Found",
"path" : "/ping/me"
}

Solution

  • See below for Spring Boot 2.* https://stackoverflow.com/a/50364513/2193477


    MvcEndpoints is responsible for reading endpoints.{name}.path configurations and somehow in its afterPropertiesSet method:

    for (Endpoint<?> endpoint : delegates) {
                if (isGenericEndpoint(endpoint.getClass()) && endpoint.isEnabled()) {
                    EndpointMvcAdapter adapter = new EndpointMvcAdapter(endpoint);
                    String path = this.applicationContext.getEnvironment()
                            .getProperty("endpoints." + endpoint.getId() + ".path");
                    if (path != null) {
                        adapter.setPath(path);
                    }
                    this.endpoints.add(adapter);
                }
    }
    

    It refusing from setting the endpoints.health.path, since isGenericEndpoint(...) is returning false for HealthEndpoint. Maybe it's a bug or something.

    Update: Apparently this was a bug and got fixed in 1.3.3.RELEASE version. So, you can use the /ping/me as your health monitoring path in this version.