The answers given here, have already provided the solution for this question. But, I was struggling in customising the actuator health endpoint for different purposes, and I would like to share my findings to help someone else as well. All examples below are for Spring Boot 2.x
.
The default actuator health endpoint would be http://localhost:8080/actuator/health.
Option 1: Change /actuator/health
to be a Custom Path like /actuator/test
Add the following to your application.properties
file
-- application.properties --
management.endpoints.web.path-mapping.health=test
the path would be: http://localhost:8080/actuator/test
Option 2: Change /actuator/health
to be a Custom Path like /myapp/test
Add the following to your application.properties
file
-- application.properties --
management.endpoints.web.base-path=/myapp
management.endpoints.web.path-mapping.health=test
the path would be: http://localhost:8080/myapp/test
Option 3: Change /actuator/health
to be a Custom Path like /health
Add the following to your application.properties
file
-- application.properties --
management.endpoints.web.base-path=/
the path would be: http://localhost:8080/health
Option 4: Change /actuator/health
to be a Custom Path like /test
Add the following to your application.properties
file
-- application.properties --
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=test
the path would be: http://localhost:8080/test
Option 5: Change Port from 8080
to custom port like 8081
Add the following to your application.properties
file. The main application will run on Port 8080
.
-- application.properties --
management.server.port=8081
the path would be: http://localhost:8081/actuator/health