loe*_*sak 5 spring spring-boot spring-boot-actuator
我有一个非常简单的弹簧启动应用程序.它只是一个zuul反向代理.除了基本设置之外,没有安全性或任何其他设置可以通过eureka和每个服务的路径映射来发现我们的服务.我试图阻止我们的执行器端点被公开暴露,但仍然希望健康检查端点用于我们的ELB但是希望它不要报告它所知道的所有服务的健康状况(我希望它灵敏).在试图找出我需要设置哪些属性以获得预期的行为时,我遇到了非常意外的行为.
例如,当我设置属性时endpoints.sensitive=true,这不会将运行状况检查端点的默认值更改为敏感.这似乎违背了文档所说的内容.
同样,您也可以选择全局设置所有端点的"敏感"标志.默认情况下,敏感标志取决于端点的类型(请参见上表).例如,要将所有端点标记为敏感信息除外:
endpoints.sensitive =真
endpoints.info.sensitive = FALSE
事实上,在调试中运行时,我从未看到过org.springframework.boot.actuate.endpoint.EndpointProperties#isSensitive调用.
要使健康端点变得敏感,我需要显式设置属性endpoints.health.sensitive=true.奇怪的是,当提供此设置时,现在org.springframework.boot.actuate.endpoint.EndpointProperties#isSensitive将被调用.
所以这很好,我的健康检查端点现在只是报告UP或DOWN而不是其他任何内容.但现在我希望运行状况检查端点是唯一启用的端点.所以我设置endpoints.enabled=false和endpoints.health.enabled=true应禁用除了健康的所有端点.但是,情况似乎并非如此.在我的情况下,我能够打/routes,/resume,/pause,/hystrix.stream,和其他人.当我用所有端点禁用endpoints.enabled=false然后启用执行器端点时,我才能确定这一点,endpoints.actuator.enabled=true并允许我点击执行器端点,然后报告这些端点已启用.
{
"links": [
{
"rel": "self",
"href": "http://localhost:9200/actuator"
},
{
"rel": "resume",
"href": "http://localhost:9200/resume"
},
{
"rel": "pause",
"href": "http://localhost:9200/pause"
},
{
"rel": "hystrix.stream",
"href": "http://localhost:9200/hystrix.stream"
},
{
"rel": "env",
"href": "http://localhost:9200/env"
},
{
"rel": "routes",
"href": "http://localhost:9200/routes"
},
{
"rel": "health",
"href": "http://localhost:9200/health"
},
{
"rel": "refresh",
"href": "http://localhost:9200/refresh"
},
{
"rel": "restart",
"href": "http://localhost:9200/restart"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我本来希望只能看到我明确启用的两个端点.
{
"links": [
{
"rel": "self",
"href": "http://localhost:9200/actuator"
},
{
"rel": "health",
"href": "http://localhost:9200/health"
}
]
}
Run Code Online (Sandbox Code Playgroud)
单独禁用每个端点似乎不会从执行器端点中删除它们,但现在当尝试访问时,我得到"此端点已禁用"消息,这是一种改进.但是我似乎无法禁用routes或者`hystrix.stream*端点,因为似乎没有公开此功能的配置.
所有这些说,我想知道这是否是预期的行为或这是一个错误?
小智 1
我遇到了与您在这里描述的相同的问题。请先检查您的 Spring Boot 版本!存在一个错误,全局“endpoints.sensitive”设置在某些指定的 Spring Boot 版本中未生效。(不确定确切的版本号。这似乎是 Spring Boot 中的重构回归。)
这里有一些参考。
在我将 Spring Boot 更新到版本 1.3.0 RELEASE 后,设置“endpoints.sensitive = true”对我来说可以正确工作。希望它也对你有用。祝你好运,伙计。
| 归档时间: |
|
| 查看次数: |
2472 次 |
| 最近记录: |