For a Spring Boot 2.1.x application where I set server.port and management.server.port to different ports I only see Tomcat and HTTP request metrics for server.port on /actuator/prometheus endpoint.
I would expect to see Tomcat metrics for both ports and HTTP metrics for requests on both ports.
Comment From: wilkinsona
I suspect that some users have the opposite expectation and consider the current behaviour to be a feature rather than a bug, particularly while there's no tag to easily identify metrics for actuator endpoints (#13435).
Comment From: snicoll
@manderson23 can you share why you need to monitor actuator endpoints?
Comment From: manderson23
@snicoll I expected consistency across all our microservices deployed on K8s.
Most have only server.port set so we see /actuator/* calls in HTTP metrics on those. We have a couple of cases where both server.port and management.server.port to support SSL while keeping actuator as http. In that case I expected Tomcat and HTTP metrics across both ports.
High request rates to actuator could impact application performance so I don't think it would be unreasonable to have them available as metrics.
Comment From: wilkinsona
9560 is related to this. We have an inconsistent story around what is and isn't applied and configured when a separate management port has been configured that we'd like to straighten out. This is another part of that.
Comment From: silvanob
I had the same expectation as @manderson23 when using the management.server.port property and I would like to see this implemented.
Comment From: somayaj
Hi, is anyone working this? Can this be worked on? Also, went back to boot 2.1.8 version and was able to see the prometheus metrics on the management port only when both server port and management port were set. Not sure if this is indeed a bug?
Comment From: mixaaaa
Hi, I don't know if it helps somebody but i could provide an option to resolve these actuator endpoint metrics by providing following two steps:
Add FilterRegistrationBean
Add configuration class not annotated to avoid duplicate registering
public class ManagementWebMvcObservationConfiguration {
private final ManagementServerProperties managementServerProperties;
public ManagementWebMvcObservationConfiguration(ManagementServerProperties managementServerProperties) {
this.managementServerProperties = managementServerProperties;
}
@Bean
public FilterRegistrationBean<ServerHttpObservationFilter> managementFilter(ObservationRegistry registry,
ObjectProvider<ServerRequestObservationConvention> customConvention,
ObservationProperties observationProperties) {
String name = observationProperties.getHttp().getServer().getRequests().getName();
ServerRequestObservationConvention convention = customConvention
.getIfAvailable(() -> new DefaultServerRequestObservationConvention(name));
ServerHttpObservationFilter filter = new ServerHttpObservationFilter(registry, convention);
FilterRegistrationBean<ServerHttpObservationFilter> registration = new FilterRegistrationBean<>(filter);
registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
registration.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.ASYNC);
registration.addUrlPatterns(requireNonNullElse(managementServerProperties.getBasePath(), "") + "/*");
return registration;
}
}
Register Bean
Add file under: "META-INF/spring/org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration.imports"
com.oneandone.bs.lom.loca.config.ManagementWebMvcObservationConfiguration
I would really not recommend this except you can make it configurable in a common library for all artifacts. But even this should not be a longtime fix. Idea for this is based on: https://github.com/spring-projects/spring-boot/issues/16098#issuecomment-1649939951