Description
Following a suggestion from @wilkinsona on this #2025 (comment), I'm opening this issue, as I believe there could be some refinement in the documentation and in the code too regarding the exposure of actuator endpoints
Reading this https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/htmlsingle/#production-ready-customizing-management-server-context-path (Using 2.1.6.RELEASE)
Unless the management port has been configured to expose endpoints by using a different HTTP port,
management.endpoints.web.base-path
is relative toserver.servlet.context-path
. Ifmanagement.server.port
is configured,management.endpoints.web.base-path
is relative tomanagement.server.servlet.context-path
.
I modified the configuration this way
+server:
+ servlet:
+ context-path: /
spring.mvc.servlet.path: /static
spring:
jersey:
application-path: /
servlet:
load-on-startup: 1
management:
endpoint:
health.enabled: true
+ endpoints:
+ web:
+ base-path: /actuator
+ path-mapping.health: healthcheck
However actuators keep showing up under /static
instead of /
curl localhost:8080/static/actuator/healthcheck
=> 200curl localhost:8080/actuator/healthcheck
=> 404
So either there's something missing on the documentation or they are some limitations to how actuator integrate when there's both spring mvc and jersey.
Even switching the dispatcher servlet to /
didn't work
-spring.mvc.servlet.path: /static
+spring.mvc.servlet.path: /
From my points over there #2025 (comment) I iterated a bit on the refinement in this area.
- The doc should state which technology it will take precedence. And as such how other properties are affected, i.e.
server.servlet.context-path
has no effect when Spring MVC is also present. - Is there a way to configure which technology will be used to expose actuators?
- Is there a way to configure an actuator only (Spring MVC) servlet ?
- If there's no way to do the above maybe indicate how to play with the DispatcherServlet or a filter that can make use of a request dispatcher.
When the spring.mvc.servlet.path: /
there this log:
Mapping servlets: oldMetricsService urls=[/metrics], company.web.JerseyConfig urls=[/*], dispatcherServlet urls=[/]
This makes sense as the Jersey app intercepts everything on /*
This last is actually interesting if one want to migrate one endpoint at a time from one technology to another.