0
votes

I am trying to add prometheus into my spring boot project. I am using spring boot actuator to expose the metrics endpoint . Did everything following tutorials but I keep on getting a 404 error. I also tried every single solution given in:

Unable to access Spring Boot Actuator "/actuator" endpoint

and

Spring Boot 2 - Actuator Metrics Endpoint not working

My dependecies:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
            <version>1.7.0</version>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
            <version>1.7.0</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-hal-explorer</artifactId>
            <version>3.5.1</version>
        </dependency>

context.xml (external properties):

 <Parameter name="management.endpoints.web.exposure.include" value="*"/>
    <Parameter name="management.security.enabled" value="false"/>
    <Parameter name="management.endpoints.beans.enabled" value="false"/>
    <Parameter name="endpoints.actuator.enabled" value="true"/>
    <Parameter name="management.endpoints.web.base-path" value="/actuator"/>
1
Given the use of context.xml, I assume you’re deploying a war file to Tomcat. What does your SpringBootServletInitializer subclass look like? What does Tomcat log when you start it?Andy Wilkinson
I am deploying the war file to Tomcat. I ctrl + shift + f and haven't found SpringBootServletInitializer anywhere. And when it comes to tomcat logs, I get about a thousand lines of code every time, though nothing that seems suspicious to me. I could pass you a link to logs if needed.aratata
Edit: I restarted the server, I don't even get same logs, now there is absolutely nothing indicting what the problem might bearatata
Without a SpringBootServletInitializer deploying your app will, essentially, do nothing. See docs.spring.io/spring-boot/docs/2.2.x/reference/htmlsingle/… for what you need to do.Andy Wilkinson
I truly doubt that since all the rest calls work fine.aratata

1 Answers

0
votes

It looks like you missing configuration in your application.yml file (If you use the application.properties file try to change code format):

  management:
      endpoint:
        health:
          show-details: always
      endpoints:
        web:
          exposure:
            include: '*'
      metrics:
        export:
          prometheus:
            enabled: false

I hope that's help you