Spring Boot 2.3.0.RELEASE /actuator/sessions endpoint is missing

Viewed 1017

For the life of me I can't get the /actuator/sessions endpoint to show up. My configuration:

management.endpoints.web.exposure.include = *
management.endpoint.sessions.enabled = true

All the docs say it should be there, but it's not. In fact, I'm missing auditevents, flyaway, jolokia, logfile, liquibase, prometheus, and sessions.

Is there some package I need to include?

3 Answers

I've checked with a sample project of spring boot 2.3.0.RELEASE for jolokia and prometheus - and by default the fact that you add the following dependencies should make it work:

For jolokia:

<dependency>
    <groupId>org.jolokia</groupId>
    <artifactId>jolokia-core</artifactId>
</dependency>

For prometheus:

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-prometheus</artifactId>
</dependency>       

In the case of jolokia you should even see the following log message:

<date goes here> INFO 5908 --- [           main] o.s.b.a.e.web.ServletEndpointRegistrar   : Registered '/actuator/jolokia' to jolokia-actuator-endpoint

There are also properties like: management.endpoint.jolokia.enabled that should be "true"

So, in short, it should be there...

You can see the full "list" of exposed endpoints by issuing a GET request to:

<host>:<port>/actuator/mappings

Apparently the sessions actuator only works if you are using clustered sessions via Spring-Session - see: https://github.com/spring-projects/spring-boot/issues/8278

If you are not using clustered sessions (and so not using Spring-Session), then it looks like you have to implement your own actuator to list the sessions.

In my case (2.3.3.RELEASE) the SessionsEndpointAutoconfiguration is not able to find a bean of type FindByIndexNameSessionRepository

SessionsEndpointAutoConfiguration#sessionEndpoint:
  Did not match:
     - @ConditionalOnBean (types: org.springframework.session.FindByIndexNameSessionRepository; SearchStrategy: all) did not find any beans of type org.springframework.session.FindByIndexNameSessionRepository (OnBeanCondition)

However, if I manually define a SessionEndpoint bean it successfully injects the FindByIndexNameSessionRepository and creates an endpoint eventually.

@Bean
SessionsEndpoint sessionsEndpoint(FindByIndexNameSessionRepository<? extends Session> sessionRepository){
        return new SessionsEndpoint(sessionRepository);
}
Related