Mr.*_*cky 3 java health-monitoring spring-boot spring-boot-actuator
我正在将一个项目从 Spring Boot 1.X 迁移到 Spring Boot 2.X。唯一剩下的并且给我带来麻烦的是 Spring Boot Actuator。
在 Spring Boot 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 Boot 注册,因为我在点击/health端点时看不到它们。
有什么建议?
通过添加以下内容修复了该问题:
management.endpoint.health.show-details=when_authorized
正如@ValentinCarnu 建议的那样。
这就是我后来在文档中发现的:https : //docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-health
默认值是never。当一个用户担任一个或多个端点角色时,他们被认为是被授权的。如果端点没有配置角色(默认),所有经过身份验证的用户都被认为是授权的。可以使用 management.endpoint.health.roles 属性配置角色。
谢谢!
| 归档时间: |
|
| 查看次数: |
3432 次 |
| 最近记录: |