17

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"
}
Vladimir Vagaytsev
  • 2,650
  • 9
  • 31
  • 30
Nagendra Kakarla
  • 791
  • 3
  • 7
  • 16

2 Answers2

30

The Actuator became technology-agnostic in Spring Boot 2.0.0, so it's not tied to MVC now. Thus if you use Spring Boot 2.0.x, you can just add the following config properties:

# custom actuator base path: use root mapping `/` instead of default `/actuator/`
management.endpoints.web.base-path=

# override endpoint name for health check: `/health` => `/ping/me`
management.endpoints.web.path-mapping.health=/ping/me

If you don't override the management.endpoints.web.base-path, your health-check will be available at /actuator/ping/me.

The properties like endpoints.* became deprecated in Spring Boot 2.0.0.

Vladimir Vagaytsev
  • 2,650
  • 9
  • 31
  • 30
6

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.

tivnet
  • 1,580
  • 14
  • 15
Ali Dehghani
  • 39,344
  • 13
  • 147
  • 138