osh*_*rko 3 java spring openshift spring-boot prometheus
我正在使用 springboot 并且我正在使用执行器和普罗米修斯公开指标。我想公开“信息”、“健康”、“指标”、“普罗米修斯”、“关机”等等。但即使我在应用程序属性中指定,我看到的是即使是根“/actuator”也暴露了。
我想禁用根执行器并且只有我之前说的 5 个成员。
有没有办法不只公开 /actuator 端点?我也试过在应用程序属性中这样做:
management.endpoints.web.exposure.exclude=actuator
Run Code Online (Sandbox Code Playgroud)
这是暴露的执行器的列表:
{
"_links": {
"self": {
"href": "http://localhost:9002/actuator",
"templated": false
},
"health-component-instance": {
"href": "http://localhost:9002/actuator/health/{component}/{instance}",
"templated": true
},
"health-component": {
"href": "http://localhost:9002/actuator/health/{component}",
"templated": true
},
"health": {
"href": "http://localhost:9002/actuator/health",
"templated": false
},
"shutdown": {
"href": "http://localhost:9002/actuator/shutdown",
"templated": false
},
"info": {
"href": "http://localhost:9002/actuator/info",
"templated": false
},
"prometheus": {
"href": "http://localhost:9002/actuator/prometheus",
"templated": false
},
"metrics-requiredMetricName": {
"href": "http://localhost:9002/actuator/metrics/{requiredMetricName}",
"templated": true
},
"metrics": {
"href": "http://localhost:9002/actuator/metrics",
"templated": false
}
}
}
Run Code Online (Sandbox Code Playgroud)
这没有配置值。您现在可以做的最好的事情是将管理基础端点移动到/,在这种情况下,发现页面被禁用以防止与应用程序中的其他端点发生冲突:
当管理上下文路径设置为 / 时,发现页面被禁用以防止与其他映射发生冲突的可能性。
如果您使用的是 Spring Security,则可以在自己的内部使用类似的内容有效地隐藏发现页面WebSecurityConfigurerAdapter:
@Override
protected void configure(HttpSecurity http) throws Exception
{
http
.authorizeRequests()
.mvcMatchers("/actuator").denyAll()
.mvcMatchers("/actuator/").denyAll()
}
Run Code Online (Sandbox Code Playgroud)
这将拒绝对发现页面的所有请求,但允许请求通过各个公开的端点。
在这个 GitHub 问题中也有一些关于发现页面的讨论:
https://github.com/spring-projects/spring-boot/issues/10331
| 归档时间: |
|
| 查看次数: |
3093 次 |
| 最近记录: |