0

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"/>
aratata
  • 1,147
  • 1
  • 6
  • 22
  • 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 Jun 01 '21 at 09:59
  • 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 Jun 01 '21 at 10:13
  • Edit: I restarted the server, I don't even get same logs, now there is absolutely nothing indicting what the problem might be – aratata Jun 01 '21 at 10:28
  • Without a `SpringBootServletInitializer` deploying your app will, essentially, do nothing. See https://docs.spring.io/spring-boot/docs/2.2.x/reference/htmlsingle/#howto-create-a-deployable-war-file for what you need to do. – Andy Wilkinson Jun 01 '21 at 11:27
  • I truly doubt that since all the rest calls work fine. – aratata Jun 01 '21 at 11:31
  • I am implementing WebApplicationInitializer in my project, might that be what you were looking for? – aratata Jun 01 '21 at 11:41
  • No, without a `SpringBootServletInitializer`, unless you’ve written a lot of code yourself, your app won’t be a Spring Boot application and you’ll miss out on all of Spring Boot’s features. It’s becoming apparent that there is lots missing from your question. Getting the help you need would be a far more efficient process if you provided a [minimal, reproducible example](/help/mcve). – Andy Wilkinson Jun 01 '21 at 11:49
  • @AndyWilkinson I added SpringBootServletInitializer , "@SpringBootApplication" and "@EnableAutoConfiguration" to my projects, so now my server should be fully integrated with spring boot. Still no actuator endpoint. – aratata Jun 04 '21 at 12:29

1 Answers1

0

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

  • I use context.xml as a external configuration file, where I tried out a lot of config variations. I had all of those parameters in my project, none made a change. – aratata Jun 01 '21 at 09:31