1

I had configured actuator in my spring boot and basically everything works fine, till I deployed file on tomcat container.

To make actuator working I needed to created additional config class:

@Configuration
@Import({ EndpointAutoConfiguration.class, PublicMetricsAutoConfiguration.class,
    HealthIndicatorAutoConfiguration.class }) public class SpringBootActuatorConfig { beans...} 

and that's working fine - but it is not use configurations, which I have in configuration (application.properties) file eg:

management.contextPath=/server

endpoints.health.path=/ping/me

but actuator still give me endpoints without "/server" path.

I tried add:

@PropertySource("classpath:/config/application.properties")

properties file is found but this not change actuator configuration.

what is a correct way to setup actuator configuration in that case?

2
  • 2
    You cannot change the contextPath when deploying a war file, the twill only work with an embedded container. Also it should just work with detecting the auto configuration, you can just not change the contextPath.
    – M. Deinum
    Jul 22, 2016 at 13:27
  • ok. So how can I setup conxtext path for all actuator endpoints? Jul 22, 2016 at 14:26

2 Answers 2

1

Spring Boot Application Properties

Scroll down to the section MANAGEMENT HTTP SERVER where you'll find this path property:

management.context-path= # Management endpoint context-path. For instance `/actuator`

This context path affects the standard management endpoints such as /beans, /env, /health, etc.

Further down the page you'll also see the section ACTUATOR PROPERTIES which has configuration properties for additional Actuator Endpoints.

Full Sample Project

6
  • it's not working. It looks like properties from application.properties file are not loaded (for actuator) Jul 22, 2016 at 17:04
  • @user1055201 Can you share a full sample project on GitHub? I'll bet there's a problem with your configuration. Jul 22, 2016 at 21:03
  • @user1055201 I've updated my answer to provide additional clarification & a full sample project. Jul 25, 2016 at 15:50
  • I already have this property setup: management.context-path=/server :) Are you able to see github project? Jul 25, 2016 at 20:08
  • @user1055201 Yes, but your example is convoluted. Example projects are expected to be minimal, complete & verifiable. See this: stackoverflow.com/help/mcve Jul 25, 2016 at 21:30
0

I also met this problem, my workaround is

@Bean
public EndpointHandlerMapping endpointHandlerMapping(Collection<? extends MvcEndpoint> endpoints) {
    EndpointHandlerMapping endpointHandlerMapping = new EndpointHandlerMapping(endpoints);
    endpointHandlerMapping.setPrefix("/manage");
    return endpointHandlerMapping;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.