Health (health
)
health
端点提供有关应用程序健康状态的详细信息。
获取应用程序健康状态
要获取应用程序的健康状态,向 /actuator/health
发送 GET
请求,如下面的基于 curl 的示例所示:
$ curl 'http://localhost:8080/actuator/health' -i -X GET \
-H 'Accept: application/json'
响应结果类似于以下内容:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 847
{
"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" : 245107195904,
"free" : 126178193408,
"threshold" : 10485760,
"path" : "/Users/zhaiyongchao/Documents/spring-docs-translation/spring-boot/spring-boot-project/spring-boot-actuator-autoconfigure/.",
"exists" : true
}
}
}
}
响应结构
响应包含应用程序健康状态的详细信息。 下表描述了响应的结构:
Path | Type | Description |
---|---|---|
|
|
Overall status of the application. |
|
|
The components that make up the health. |
|
|
Status of a specific part of the application. |
|
|
The nested components that make up the health. |
|
|
Details of the health of a specific part of the application. Presence is controlled by |
注意:上面的响应字段适用于 V3 API。
如果您需要返回 V2 JSON,您应该使用 accept header 或 application/vnd.spring-boot.actuator.v2+json
获取组件健康状态
要获取应用程序健康状态中特定组件的健康状态,向 /actuator/health/{component}
发送 GET
请求,如下面的基于 curl 的示例所示:
$ 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()"
}
}
获取嵌套组件健康状态
如果特定组件包含其他嵌套组件(如上面示例中的 broker
指示器),可以通过向 /actuator/health/{component}/{subcomponent}
发送 GET
请求来获取此类嵌套组件的健康状态,如下面的基于 curl 的示例所示:
$ 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 中的任意数量的 /{component}
标识符,以允许获取任何深度的组件健康状态。