Spring Boot Actuator paths not enabled by default?

Viewed 3761

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.

3 Answers

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

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)

Related