3

I am working on a Spring Boot project where actuator health is configured on port 8090 where as application on 8080.

I would like to intercept incoming actuator health requests in order to customize it.

Tried adding an interceptor as below:

public class ActuatorConfig extends WebMvcEndpointManagementContextConfiguration {
     @Override
     public WebMvcEndpointHandlerMapping webMvcEndpointHandlerMapping(.....) {
         WebMvcEndpointHandlerMapping mapping = super.webMvcEndpointHandlerMapping(...);
         mapping.setInterceptors(myActuatorInterceptor());  
     }

     @Bean
     public MyActuatorInterceptor myActuatorInterceptor(){
      return new MyActuatorInterceptor(); 
     }
}

public class MyActuatorInterceptor extends HandlerInterceptor {
     @Override
     public boolean preHandle(...) {
         //my customization code
     }
}

When I add the above Interceptor strangely '/actuator/health' requests return '404 not found' on port 8090 even though it exists where as it's working fine on port 8080.

When I disable Interceptor code '/actuator/health' requests works fine on 8090.

Question: How to intercept '/actuator/health' request when its running on a different port?

Prasant
  • 41
  • 1

0 Answers0