Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing spring boot actuator health end point to a custom end point

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?

like image 984
ACP Avatar asked Oct 04 '18 20:10

ACP


People also ask

How do you expose a custom endpoint in a spring boot?

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.

What property is needed to customize port for actuator management endpoints?

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.

How do I change the port on an actuator?

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 .


1 Answers

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
like image 86
The Gilbert Arenas Dagger Avatar answered Sep 30 '22 13:09

The Gilbert Arenas Dagger