Adam
Adam

Reputation: 2269

Spring Boot Actuator paths not enabled by default?

While updating my Spring Boot application to the latest build snapshot and I am seeing that none of the actuator endpoints are enabled by default. If I specify them to be enabled in application.properties, they show up.

1) Is this behavior intended? I tried searching for an issue to explain it but couldn't find one. Could somebody link me to the issue / documentation?

2) Is there a way to enable all the actuator endpoints? I often find myself using them during development and would rather not maintain a list of them inside my properties file.

Upvotes: 5

Views: 5551

Answers (3)

Codigo Morsa
Codigo Morsa

Reputation: 840

UPDATE: use this only in dev environment, not in production!

Is there a way to enable all the actuator endpoints?

Using Spring Boot 2.2.2 Release, this worked for me:

On the file src/main/resources/application.properties add this:

management.endpoints.web.exposure.include=*

To check enabled endpoints go to http://localhost:8080/actuator

Source: docs.spring.io

Upvotes: 0

firstpostcommenter
firstpostcommenter

Reputation: 2911

Even if we enable all the actuator endpoints as below management.endpoints.web.exposure.include=* (In case of YAML the star character should be surrounded by double quotes as "*" because star is one of the special characters in YAML syntax)

The httptrace actuator endpoint will still not be enabled in web by default. HttpTraceRepository interface need to be implemented to enable httptrace (See Actuator default endpoints, Actuator endpoints, Actuator httptrace).

@Component
public class CustomHttpTraceRepository implements HttpTraceRepository {

    AtomicReference<HttpTrace> lastTrace = new AtomicReference<>();

    @Override
    public List<HttpTrace> findAll() {
        return Collections.singletonList(lastTrace.get());
    }

    @Override
    public void add(HttpTrace trace) {
        if ("GET".equals(trace.getRequest().getMethod())) {
            lastTrace.set(trace);
        }
    }
}

Now the endpoints can be accessed using the url,

http://localhost:port/actuator/respective-actuator-endpoint 

(Example http://localhost:8081/actuator/httptrace)

If there is a management.servlet.context-path value present in properties file then the URL will be,

http://localhost:port/<servlet-context-path>/respective-actuator-endpoint 

(Example http://localhost:8081/management-servlet-context-path-value/httptrace)

Upvotes: 0

glytching
glytching

Reputation: 47865

Two parts to this answer:

"Is there a way to enable all the actuator endpoints?"

Add this property endpoints.enabled=true rather than enabling them individually with endpoints.info.enabled=true, endpoints.beans.enabled=true etc

Update: for Spring Boot 2.x the relevant property is:

endpoints.default.web.enabled=true

"Is this behavior intended?"

Probably not. Sounds like you might have spotted an issue with the latest milestone. If you have a reproducible issue with a Spring Boot milestone then Spring's advice is ...

Reporting Issues

Spring Boot uses GitHub’s integrated issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:

Before you log a bug, please search the issue tracker to see if someone has already reported the problem.

If the issue doesn’t already exist, create a new issue.

Upvotes: 4

Related Questions