Reputation: 41
After moving from spring-boot v1.3 to the newest spring-boot v2.2.4 we've lost the ability to have custom endpoints under management port.
Before we had our custom endpoints declared as:
@Component
public class CacheEndpoint implements MvcEndpoint {
...
@Override
public String getPath() {
return "/v1/cache";
}
...
// mappings goes here
Since MvcEndpoint
has been removed from spring-boot actuator now we need to do next:
@Component
@RestControllerEndpoint(id = "cache")
public class CacheEndpoint {
...
// mappings goes here
Unfortunately, we've lost an option to have a custom root path for our custom management endpoints (before it was /v1/
)
For back-compatibility, we still want to have default actuator endpoints such as health
, metrics
, env
.. to be under /
base path. e.g. host:<management_port>/health
, but at the same time we still want to support our custom endpoints under /v1/
path, e.g. host:<management_port>/v1/cache
I tried a lot of things, googled
even more, but no success yet.
Is there a way to achieve this?
Upvotes: 0
Views: 716
Reputation: 42441
This is what I use for spring boot 2:
application.yml:
management:
endpoints:
enabled-by-default: true
web:
exposure:
include: "*"
base-path: "/management" # <-- note, here is the context path
All-in-all consider reading a migration guide for actuator from spring boot 1.x to 2.x
Upvotes: 1