13

I am creating a demo project for Spring-Config-Server and Spring-Config-Client.

In SpringBoot 1.5.6.RELEASE everything is working fine.

However, when I am upgrading project to 2.0.1.RELEASE it does not provide the actuator endpoints.


Actuator endpoint provided in 1.5.6.RELEASE

Mapped "{[/refresh || /refresh.json],methods=[POST]}"
Mapped "{[/dump || /dump.json],methods=[GET]
Mapped "{[/heapdump || /heapdump.json],methods=[GET]
Mapped "{[/autoconfig || /autoconfig.json],methods=[GET]
Mapped "{[/resume || /resume.json],methods=[POST]}"
Mapped "{[/configprops || /configprops.json],methods=[GET]
Mapped "{[/features || /features.json],methods=[GET]
Mapped "{[/loggers/{name:.*}],methods=[GET]
Mapped "{[/restart || /restart.json],methods=[POST]}"
...and many more

Actuator endpoint provided in 2.0.1.RELEASE

Mapped "{[/actuator/health],methods=[GET]
Mapped "{[/actuator/info],methods=[GET]
Mapped "{[/actuator],methods=[GET]

pom.xml : 2.0.1.RELEASE

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

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.RC1</spring-cloud.version>
    </properties>

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>

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

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

The only difference bw 1.5.6 pom is version and spring-cloud.version = Dalston.SR2

Could someone please help?

Mehraj Malik
  • 14,872
  • 15
  • 58
  • 85

6 Answers6

32

After a bit of research, I have found the cause why the endpoints are not shown in Spring Boot 2.0 is as per the spring docs

Since Endpoints may contain sensitive information, you should carefully consider when to expose them. The following table shows the default exposure for the built-in endpoints:

so, we need to expose them manually.

I have added management.endpoints.web.exposure.include=* in application.properties file and now all the actuator endpoints are exposed via HTTP .

Note: If you are using .yml make sure to use "*" not *

We can also exclude actuator which we don't want to expose using the property management.endpoints.web.exposure.exclude= shutdown,liquibase

Mehraj Malik
  • 14,872
  • 15
  • 58
  • 85
  • Hm, that's really weird. The docs state that the endpoints are *enabled* by default, which was definitely not the case for me (and it seems for you too!). Perhaps the docs are wrong? – filpa Aug 21 '18 at 10:09
  • 9
    You need to understand the difference between enabled and exposed via web endpoint. Enabled endpoint is not necessarily exposed via web. Currently by default most endpoints are enabled. Most of them are also exposed via JMX, but only "info" and "health" are exposed via web (http). Documentation clearly states all of this if you read it. – user1918305 Oct 18 '18 at 15:59
8

refresh endpoint can be enabled to use via web (exposed via web), using this in application.yaml

management.endpoints.web.exposure.include: health,info,refresh

Spring Boot enables health and info endpoints by default. It is necessary to list them to keep them enabled.

If your application has this URL http://localhost:8181

You can send POST request to refresh

http://localhost:8181/actuator/refresh

v.ladynev
  • 19,275
  • 8
  • 46
  • 67
7

Exposure of endpoints on HTTP is now configurable by using properties

management.endpoints.web.exposure.include
management.endpoints.web.exposure.exclude

You can expose endpoints by there ID mentioned by Actuator.

# Include all endpoints 
management.endpoints.web.exposure.include=*
# Exclude specifics 
management.endpoints.web.exposure.exclude=env
Mahesh Pardeshi
  • 143
  • 1
  • 9
6

Even after adding the below line, it wont help sometimes

management.endpoints.web.exposure.include=*

Try this:- Refresh works on OPTIONS method, not with POST method for few cases.

enter image description here

svarog
  • 9,477
  • 4
  • 61
  • 77
Sireesh Yarlagadda
  • 12,978
  • 3
  • 74
  • 76
0

This is what I did. Enabled all the endpoints by setting

management.endpoints.web.exposure.include=*

And sent an empty request to refresh endpoint.

curl -d '{}' -H 'Content-Type: application/json' http://localhost:8000/actuator/refresh

URL http://localhost:8000/actuator/ will list all the available endpoints.

P.S.: My app is running on port 8000. On default port 8080, I am running Config server.

user2791560
  • 39
  • 1
  • 6
0

To enable refresh, add following properties to your application properties file

management.endpoints.web.exposure.include=health,info,refresh 
management.endpoint.refresh.enabled=true