Spring Boot 2 Actuator /health 端点在使用身份验证时不显示附加信息
Spring Boot 2 Actuator /health endpoint not showing additional info when using authentication
我正在将项目从 Spring Boot 1.X 迁移到 Spring Boot 2.X。唯一给我带来麻烦的是 Spring 引导执行器。
在 Spring 引导 1.X 中,当您使用凭据点击 /health 端点时,您通常会收到更详细的指标列表,例如例如默认 org.springframework.boot.actuate.health.DiskSpaceHealthIndicator.
的结果
{
"status": "UP",
"diskSpace": {
"status": "UP",
"total": 1000240963584,
"free": 909162590208,
"threshold": 10485760
}
}
我也会在这里看到自定义的健康指标。
现在我使用更新版本的 Actuator 库,我不再收到该附加信息(在提供凭据时)。我只看到:
{
"status": "UP"
}
起初我以为我可能没有正确设置凭据,但通过故意提供无效凭据,我得到了 401 Unauthorized。所以不能是认证。
我使用调试器进行了更深入的研究,发现实际上创建了 DiskSpaceHealthIndicator bean,以及所有其他自定义指标。但似乎它们没有被 Spring 注册,引导我在点击 /health 端点时看不到它们。
有什么建议吗?
问题已通过添加解决:
management.endpoint.health.show-details=when_authorized
正如@ValentinCarnu 所建议的那样。
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.
谢谢!
不要使用这个 URL http://localhost:8080/env
而是使用 http://localhost:8080/actuator/env
并使用以下内容设置 Application.properties
management.security.enabled=假
management.endpoints.web.exposure.include=*
为我工作
我正在将项目从 Spring Boot 1.X 迁移到 Spring Boot 2.X。唯一给我带来麻烦的是 Spring 引导执行器。
在 Spring 引导 1.X 中,当您使用凭据点击 /health 端点时,您通常会收到更详细的指标列表,例如例如默认 org.springframework.boot.actuate.health.DiskSpaceHealthIndicator.
的结果
{
"status": "UP",
"diskSpace": {
"status": "UP",
"total": 1000240963584,
"free": 909162590208,
"threshold": 10485760
}
}
我也会在这里看到自定义的健康指标。
现在我使用更新版本的 Actuator 库,我不再收到该附加信息(在提供凭据时)。我只看到:
{
"status": "UP"
}
起初我以为我可能没有正确设置凭据,但通过故意提供无效凭据,我得到了 401 Unauthorized。所以不能是认证。
我使用调试器进行了更深入的研究,发现实际上创建了 DiskSpaceHealthIndicator bean,以及所有其他自定义指标。但似乎它们没有被 Spring 注册,引导我在点击 /health 端点时看不到它们。
有什么建议吗?
问题已通过添加解决:
management.endpoint.health.show-details=when_authorized
正如@ValentinCarnu 所建议的那样。
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.
谢谢!
不要使用这个 URL http://localhost:8080/env 而是使用 http://localhost:8080/actuator/env
并使用以下内容设置 Application.properties
management.security.enabled=假 management.endpoints.web.exposure.include=*
为我工作