Spring Boot 2 Actuator /health endpoint not showing additional info when using authentication

Mr. Nicky :

I'm in the midst of migrating a project from Spring Boot 1.X to Spring Boot 2.X. The only thing that's left and that's giving me trouble is the Spring Boot Actuator.

In Spring Boot 1.X when you hit the /health endpoint with credentials, you would normally receive a more detailed list of indicators, like for example the result of the default org.springframework.boot.actuate.health.DiskSpaceHealthIndicator.

{ "status": "UP", "diskSpace": { "status": "UP", "total": 1000240963584, "free": 909162590208, "threshold": 10485760 } }

I would also see custom defined Health indicators here as well.

Now that I use the newer version of the Actuator library, I no longer receive that additional information (when providing credentials). All I see is:

{ "status": "UP" }

At first I thought that maybe I haven't set up the credentials properly, but by intentionally providing invalid credentials I get 401 Unauthorized. So it can't be the authentication.

I digged in a little deeper with the debugger and saw that the DiskSpaceHealthIndicator bean actually gets created, along with all my other custom defined indicators. But it seems like they do not get registered by Spring Boot for me to not see them when hitting the /health endpoint.

Any suggestions?

Mr. Nicky :

The issue was fixed by adding:

management.endpoint.health.show-details=when_authorized

as @ValentinCarnu suggested.

And this is what I found afterwards in the documentation: https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-health

The default value is never. A user is considered to be authorized when they are in one or more of the endpoint’s roles. If the endpoint has no configured roles (the default) all authenticated users are considered to be authorized. The roles can be configured using the management.endpoint.health.roles property.

Thanks!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=135456&siteId=1