Search code examples
javaspringspring-bootmetricsspring-boot-actuator

Metrics endpoint isn't available since Spring Boot 2.0.2-RELEASE


Starting with Spring Boot 2.0.2-RELEASE actuator 'metrics' endpoint isn't available even using following configuration:

management:
  endpoints.web.exposure.include: "*"

The same configuration exposes metrics endpoint with Spring Boot 2.0.0-RELEASE

pom.xml:

    ...
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-webflux</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    ...
    <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-registry-prometheus</artifactId>
    </dependency>
    <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-core</artifactId>
    </dependency>
    ....

Any ideas how to resolve this issue?


Solution

  • Finally I found that there is an instance of org.springframework.boot.actuate.metrics.MetricsEndpoint should exist in Spring context in order to let Actuator show '/metrics' endpoint.

    org.springframework.boot.actuate.autoconfigure.metrics.MetricsEndpointAutoConfiguration
    

    is responsible to create an instance of MetricsEndpoint but for some reason it never creates it.

    So, I've created this bean in my own configuration:

        @Bean
        public MetricsEndpoint metricsEndpoint(MeterRegistry registry) {
            return new MetricsEndpoint(registry);
        }
    

    It's fixed the problem but I'm not sure this this the best solution.