我有一個非常簡單的spring啓動應用程序。它只是一個zuul反向代理。除了基本設置之外,沒有任何安全性或任何其他功能可通過eureka和每個服務的路徑映射來發現我們的服務。我試圖阻止我們的執行器端點被公開暴露,但仍希望將健康檢查端點用於我們的ELB,但不希望它報告它意識到的所有服務的健康狀況(我希望它靈敏)。在試圖弄清楚我需要設置哪些屬性以獲得預期的行爲時,我遇到了非常意外的行爲。Spring Boot Actuator端點配置似乎不像預期的那樣工作
例如,當我設置屬性endpoints.sensitive=true
時,這不會將健康檢查端點的默認值更改爲敏感。這似乎違背了文檔所述的內容。
同樣的,你也可以選擇全局設置的 所有端點的「敏感」的標誌。默認情況下,敏感標誌取決於端點的類型(請參見上表)。例如,以紀念所有端點作爲 除了信息敏感:
endpoints.sensitive =真
endpoints.info.sensitive =假
事實上,在調試運行的時候,我從來沒有看到org.springframework.boot.actuate.endpoint.EndpointProperties#isSensitive
被調用。
爲了讓健康端點變得敏感,我需要明確設置屬性。奇怪的是,當這個設置提供時,現在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"
}
]
}
我會期望只看到我明確啓用的兩個端點。
{
"links": [
{
"rel": "self",
"href": "http://localhost:9200/actuator"
},
{
"rel": "health",
"href": "http://localhost:9200/health"
}
]
}
禁用每個端點單獨似乎沒有試圖訪問時,從執行端點刪除它們,但現在,我得到一個「此端點被禁用」的消息這是一種進步。然而,我似乎無法禁用routes
或`hystrix.stream *端點,因爲似乎沒有配置可以顯示此功能。
所有這一切說,我想知道這是預期的行爲還是這是一個錯誤?
爲此創建了兩個錯誤:https://github.com/spring-projects/spring-boot/issues/7477和https://github.com/spring-projects/spring-boot/issues/7476 – loesak