英文:
springboot 2.3.0 actuator liveness/readiness check returns wrong response
问题
I am trying to test liveness/readiness locally using spring boot 2.3.0. When I expose API, it does return the right status, but not the right response. Based on https://spring.io/blog/2020/03/25/liveness-and-readiness-probes-with-spring-boot, I am expecting components, diskSpace and etc when I expose /actuator/health
, but I am getting:
{
"status": "UP",
"groups": [
"liveness",
"readiness"
]
}
I am pretty sure my pom.xml is right since it returns the right status. I think it has something to do with configuration. Here is my local setup for configuration (application.properties):
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.url=jdbc:sqlserver://myurl.net;database
spring.datasource.username=username
spring.datasource.password=password
management.health.probes.enabled=true
management.endpoint.health.group.readiness.include=readinessProbe,db
Am I missing something? Even if I call /actuator/health/liveness, all I am getting is:
{
"status": "UP"
}
"status" does show the right value (UP or DOWN), but components are missing.
英文:
I am trying to test liveness/readiness locally using spring boot 2.3.0. When I expose API, it does return the right status, but not the right response. Based on https://spring.io/blog/2020/03/25/liveness-and-readiness-probes-with-spring-boot, I am expecting components, diskSpace and etc when I expose /actuator/health
, but I am getting:
{
"status": "UP",
"groups": [
"liveness",
"readiness"
]
}
I am pretty sure my pom.xml is right since it returns right status. I think it has something to do with configuration. Here is my local setup for configuration (application.properties):
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.url=jdbc:sqlserver://myurl.net;database
spring.datasource.username=username
spring.datasource.password=password
management.health.probes.enabled=true
management.endpoint.health.group.readiness.include=readinessProbe,db
Am I missing something? Even if I call /actuator/health/liveness, all I am getting is
{
"status": "UP"
}
"status" does show the right value (UP or DOWN), but components are missing.
答案1
得分: 2
健康端点公开的信息取决于management.endpoint.health.show-details
和management.endpoint.health.show-components
属性,这些属性可以配置为以下之一的值:never
,when-authorized
,always
。默认值是never
。
因此,如果您将management.endpoint.health.show-components
的值设置为always
,它应该显示您期望的内容。
有关更多详细信息,请参考此处的文档。
英文:
The information exposed by the health endpoint depends on the management.endpoint.health.show-details
and management.endpoint.health.show-components
properties which can be configured with one of the following values never
, when-authorized
, always
.The default value is never
.
So if you set value of management.endpoint.health.show-components
to always
it should show what you are expecting.
For more details refer to the docs here
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论