springboot 2.3.0 actuator liveness/readiness check 返回错误的响应

huangapple go评论107阅读模式
英文:

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-detailsmanagement.endpoint.health.show-components属性,这些属性可以配置为以下之一的值:neverwhen-authorizedalways。默认值是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

huangapple
  • 本文由 发表于 2020年8月5日 21:51:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/63266668.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定