Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get my prometheus endpoint with spring boot 3.0 and webflux?

I've been working with spring boot 2.7 and its tomcat server. Today, I'm trying out spring 3 with webflux and netty. As always I want to add the prometheus endpoint but I can't seem to make it work. Here's what I did:

I added the following dependencies:

        <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>
            <!-- Required for the prometheus actuator endpoint -->
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
        </dependency>

I have done the following configuration:

management:
  endpoint:
    metrics.enabled: true
    prometheus.enabled: true
  endpoints.web:
    # Removing /actuator from all paths
    base-path: /
    path-mapping:
      prometheus: metrics
    exposure.include: health,prometheus

But whenever I call /metrics that usually works on all my other projects I get a 404. I've tried removing all the specificities like the path-mapping or the base-path change to no avail.

I'm kinda stuck at this point. What am I missing here?

like image 880
Crystark Avatar asked Oct 18 '25 00:10

Crystark


1 Answers

The properties are renamed in Spring Boot 3: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#actuator-metrics-export-properties

In my case I changed

management:
  metrics:
    export:
      prometheus:
        enabled: true

to

management:
  prometheus:
    metrics:
      export:
        enabled: true
like image 160
ivaylo Avatar answered Oct 19 '25 12:10

ivaylo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!