|
对于最新稳定版本,请使用Spring Boot 4.0.0! |
健康(健康)
这健康端点提供关于应用健康状况的详细信息。
检索应用程序的健康状态
要检索应用程序的健康状况,请设置获取请求/执行器/健康如以下基于卷度的示例所示:
$ curl 'http://localhost:8080/actuator/health' -i -X GET \
-H 'Accept: application/json'
最终的响应类似于以下内容:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 821
{
"status" : "UP",
"components" : {
"broker" : {
"status" : "UP",
"components" : {
"us1" : {
"status" : "UP",
"details" : {
"version" : "1.0.2"
}
},
"us2" : {
"status" : "UP",
"details" : {
"version" : "1.0.4"
}
}
}
},
"db" : {
"status" : "UP",
"details" : {
"database" : "H2",
"validationQuery" : "isValid()"
}
},
"diskSpace" : {
"status" : "UP",
"details" : {
"total" : 76887154688,
"free" : 51270258688,
"threshold" : 10485760,
"path" : "/home/runner/work/spring-boot/spring-boot/spring-boot-project/spring-boot-actuator-autoconfigure/.",
"exists" : true
}
}
}
}
恢复组件的健康状态
要获取应用程序健康状态中某一特定组件的健康状态,请设置获取请求/actuator/health/{component}如以下基于卷度的示例所示:
$ curl 'http://localhost:8080/actuator/health/db' -i -X GET \
-H 'Accept: application/json'
最终的响应类似于以下内容:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 101
{
"status" : "UP",
"details" : {
"database" : "H2",
"validationQuery" : "isValid()"
}
}
获取嵌套组件的健康状态
如果某个特定组件包含其他嵌套组件(如代理上述示例中的指示符),可以通过发出获取请求/actuator/health/{component}/{subcomponent}如以下基于卷度的示例所示:
$ curl 'http://localhost:8080/actuator/health/broker/us1' -i -X GET \
-H 'Accept: application/json'
最终的响应类似于以下内容:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 66
{
"status" : "UP",
"details" : {
"version" : "1.0.2"
}
}
应用程序健康状态的组成部分可能根据应用程序的健康指标及其分组方式,嵌入任意深度。
健康端点支持任意数量的/{组件}URL中的标识符,允许在任何深度检索组件的健康状态。