Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot /actuator returns 404 not found

I am using spring boot 2.1.4.RELEASE and currently trying to access http://localhost:8080/actuator but i am getting 404 not found. I am not sure what am i doing wrong here. Below is my pom dependencies-

 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.dir</groupId>
    <artifactId>api</artifactId>
    <version>2.4.0</version>
    <packaging>jar</packaging>

    <name>Search</name>
    <description>Search</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <distributionManagement>
        <repository>
            <id>Releases</id>
            <name>repo1.releases</name>
            <url>http://www.something.com</url>
        </repository>
        <snapshotRepository>
            <id>Snapshots</id>
            <name>repo1.com</name>
            <url>http://repo1.com/artifactory/Snapshots</url>
        </snapshotRepository>
    </distributionManagement>


    <properties>
        <!--These two should be in all ParentPOMs -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- Keep this version in sync with the pom's version ignoring "-SNAPSHOT" -->
        <applicationVersion>1.0.0</applicationVersion>
        <elasticsearch.version>5.2.0</elasticsearch.version>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.4.0</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.4.0</version>
        </dependency>


        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>1.5.7</version>
        </dependency>



        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.0</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>x-pack-transport</artifactId>
            <version>5.2.1</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>5.2.0</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>5.2.0</version>
        </dependency>

        <dependency>
            <groupId>apache-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.1</version>
        </dependency>



        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.7.0</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <!-- Spring boot actuator to expose metrics endpoint -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <!-- Micormeter core dependecy  -->
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
        </dependency>
        <!-- Micrometer Prometheus registry  -->
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
        </dependency>




    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <environmentVariables>
                        <version>9.9.9</version>
                        <basePath>http://sample-basepath.com</basePath>

                    </environmentVariables>
                </configuration>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>

    </build>


</project>

properties file config

management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
management.endpoint.health.show-details=always
management.endpoint.beans.enabled=true

when i run the application i do see this in console

2019-04-27 00:04:25.406  INFO 32522 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 16 endpoint(s) beneath base path '/actuator'
2019-04-27 00:04:25.534  INFO 32522 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path '/myendpoint'
like image 456
Jon Abraham Avatar asked Apr 27 '19 04:04

Jon Abraham


4 Answers

Certain actuator endpoints are disabled, and have to be enabled before you can use them. I was trying to access /actuator/beans, which turns out to be just such an endpoint. According to the docs, all you need is to enable them in your application.properties file:

management.endpoints.web.exposure.include=health,info,beans
like image 141
teuber789 Avatar answered Sep 29 '22 04:09

teuber789


Please check if you have configured server.servlet.contextPath=/myendpoint

If you have done like this please try localhost:8080/{server.servlet.contextPath}/actuator

like image 33
RAJKUMAR NAGARETHINAM Avatar answered Sep 29 '22 05:09

RAJKUMAR NAGARETHINAM


I had the same 404 error, even after exactly following Spring documentation. What finally worked for me was deleting actuator dependency and the jar, and adding it again, with a mvn clean install. It worked :)

like image 34
Manisha Avatar answered Sep 29 '22 05:09

Manisha


I'm using a spring boot. I got this simple message from spring boot.😇

Spring Boot /actuator returns 404 not found

here is my application.yml file.

server:
  port: 6150
  servlet:
    context-path: /


management:
  server:
    port: 6150
  endpoints:
    web:
      base-path: /actuator
      exposure:
        include: "*"

and then:

http://localhost:6150/actuator

I know this question is quit old and some situation(condition) is different.
I hopefully someone save their time.

like image 36
daim tak Avatar answered Sep 29 '22 04:09

daim tak