Is it possible to change the spring boot actuator health end point to a custom end point? Something like the below.
http://localhost:8080/actuator/health
to
http://localhost:8080/myapp/apphealth
Wanted only the name change but not the response of the actuator/health. Is it possible?
To create a custom actuator endpoints, Use @Endpoint annotation on a class. Then leverage @ReadOperation / @WriteOperation / @DeleteOperation annotations on the methods to expose them as actuator endpoint bean as needed.
address is the property used to specify the list of addresses from where we want to listen. If we want to listen to management requests only from the localhost, then specify the property value as 127.0. 0.1. For this to work, the management endpoint must be configured to a different port from the HTTP port.
In a standalone application, the Actuator HTTP port defaults to the same as the main HTTP port. To make the application listen on a different port, set the external property: management. server. port .
Yes, it is possible.
How to customize the paths to your actuator endpoints is defined in this section of the documentation.
The documentation states:
If you want to map endpoints to a different path, you can use the management.endpoints.web.path-mapping property.
The following example remaps /actuator/health to /healthcheck:
application.properties.
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=healthcheck
So, in your case you want:
-- application.properties --
management.endpoints.web.base-path=/myapp
management.endpoints.web.path-mapping.health=apphealth
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With