Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
}
like image 709
Nagendra Kakarla Avatar asked Feb 17 '16 19:02

Nagendra Kakarla


People also ask

What is healthendpoint in Spring Boot?

Spring boot makes health checks easier for us by providing opinionated /actuator/health endpoint. The HealthEndpoint of spring-boot-starter-actuator module collects Health information for any beans that are defined as HealthIndicator. For a simple web application, there are two HealthIndicator beans Auto-Configured by default.

How to check the health status of a Spring Boot application?

In order to inspect the health status of a Spring Boot application, we can call the /actuator/health endpoint. This endpoint will report an aggregated result of all registered HealthIndicator s. Also, to see the health report from one specific indicator, we can call the /actuator/health/ {name} endpoint.

How do I expose an endpoint in Spring Boot actuator?

If you are developing a Spring MVC application, Spring Boot Actuator will auto-configure all enabled endpoints to be exposed over HTTP. The default convention is to use the id of the endpoint as the URL path. For example, health is exposed as /health.

What is diskspace and pinghealthindicator in Spring Boot response?

The response contains two components objects which are diskSpace and ping These two health information come from DiskSpaceHealthIndicator and PingHealthIndicator respectively. Usually, starters comes with their own health indicator auto-configurations. For Example, adding spring-boot-starter-jdbc adds a database Health check.


1 Answers

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.

like image 53
Vladimir Vagaytsev Avatar answered Sep 23 '22 12:09

Vladimir Vagaytsev