0

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?

Alex Angrybambr
  • 41
  • 1
  • 1
  • 4

1 Answers1

1

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

Mark Bramnik
  • 39,963
  • 4
  • 57
  • 97
  • That works, but for ALL endpoints, including actuator's default. E.g. /health, /metrics become /manage/health, /manage/metrics etc.. But we need to save base-path=/ for default actuator's endpoints and apply another base-path for out custom endpoints only . – Alex Angrybambr Feb 17 '20 at 13:13
  • I don't remember that I needed something like this in spring boot 1.x but why don't you just put a path /actuator/custom/path/my-custom-endpoint ? All-in-all I believe all endpoints for actuator should be under the same root path – Mark Bramnik Feb 17 '20 at 13:22
  • It's a back-compatibility reason. Of course, we can move everything under one path, but there are a lot of things need to be reconfigured because of this. In edge case we will do this, but if there a way to configure this at the application level - better not to reconfigure a number of third-parties. – Alex Angrybambr Feb 17 '20 at 13:28