Add prefix to all Spring Boot actuator endpoints
Solution 1
Jesper's answer is completely right, but I was looking for a more straightforward way of prefixing all endpoints, and it can be done with management.context-path
, e.g.:
management:
context-path: /secure
-> /secure/env
-> /secure/health
...
Solution 2
According to current Spring-Boot documentation, the property to change is:
management.endpoints.web.base-path=/secure
Solution 3
Set the properties endpoints.{name}.path
in your application.properties
. For example:
endpoints.actuator.path=/secure/actuator
endpoints.env.path=/secure/env
endpoints.health.path=/secure/health
endpoints.info.path=/secure/info
To enable security on an endpoint, set endpoints.{name}.sensitive
to true
. For example:
endpoints.health.sensitive=true
See also Securing sensitive endpoints, Actuator Security and HTTP health endpoint access restrictions in the Spring Boot reference documentation if you want to secure the actuator endpoints of your application.
See Common application properties in the Spring Boot reference documentation for a list of common properties that you can set in application.properties
.
Related videos on Youtube
codependent
By day: I code for 8 hours and a half. Cloud, Kubernetes, Spring, NodeJS... By night: I code a little more, work out and try to get some sleep.
Updated on July 09, 2022Comments
-
codependent almost 2 years
Is there an easy way to add a prefix to all the Actuator endpoints?
/env -> /secure/env /health -> /secure/health /info -> /secure/info ...
-
Ivar over 5 yearsChanged in Spring Boot 2 to
management.endpoints.web.base-path
docs.spring.io/spring-boot/docs/2.1.x/reference/htmlsingle/… -
Jesper over 4 years@Steffi things have changed in Spring Boot 2. See the documentation: Actuator properties
-
nekperu15739 over 4 yearsplease add version to be more explicit