此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Boot 3.3.1Spring中文文档

此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Boot 3.3.1Spring中文文档

终结点提供有关应用程序运行状况的详细信息。healthSpring中文文档

检索应用程序的运行状况

若要检索应用程序的运行状况,请向 发出请求,如以下基于 curl 的示例所示:GET/actuator/healthSpring中文文档

$ curl 'http://localhost:8080/actuator/health' -i -X GET \
    -H 'Accept: application/json'

生成的响应类似于以下内容:Spring中文文档

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" : 77851254784,
        "free" : 38342938624,
        "threshold" : 10485760,
        "path" : "/home/runner/work/spring-boot/spring-boot/spring-boot-project/spring-boot-actuator-autoconfigure/.",
        "exists" : true
      }
    }
  }
}

响应结构

响应包含应用程序运行状况的详细信息。 下表描述了响应的结构:Spring中文文档

路径 类型 描述

statusSpring中文文档

StringSpring中文文档

应用程序的整体状态。Spring中文文档

componentsSpring中文文档

ObjectSpring中文文档

构成运行状况的组件。Spring中文文档

components.*.statusSpring中文文档

StringSpring中文文档

应用程序特定部分的状态。Spring中文文档

components.*.componentsSpring中文文档

ObjectSpring中文文档

构成运行状况的嵌套组件。Spring中文文档

components.*.detailsSpring中文文档

ObjectSpring中文文档

应用程序特定部分的运行状况的详细信息。状态由 控制。management.endpoint.health.show-detailsSpring中文文档

上面的响应字段适用于 V3 API。 如果需要返回 V2 JSON,则应使用 accept 标头或application/vnd.spring-boot.actuator.v2+json
路径 类型 描述

statusSpring中文文档

StringSpring中文文档

应用程序的整体状态。Spring中文文档

componentsSpring中文文档

ObjectSpring中文文档

构成运行状况的组件。Spring中文文档

components.*.statusSpring中文文档

StringSpring中文文档

应用程序特定部分的状态。Spring中文文档

components.*.componentsSpring中文文档

ObjectSpring中文文档

构成运行状况的嵌套组件。Spring中文文档

components.*.detailsSpring中文文档

ObjectSpring中文文档

应用程序特定部分的运行状况的详细信息。状态由 控制。management.endpoint.health.show-detailsSpring中文文档

上面的响应字段适用于 V3 API。 如果需要返回 V2 JSON,则应使用 accept 标头或application/vnd.spring-boot.actuator.v2+json

检索组件的运行状况

若要检索应用程序运行状况的特定组件的运行状况,请向 发出请求,如以下基于 curl 的示例所示:GET/actuator/health/{component}Spring中文文档

$ curl 'http://localhost:8080/actuator/health/db' -i -X GET \
    -H 'Accept: application/json'

生成的响应类似于以下内容:Spring中文文档

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 101

{
  "status" : "UP",
  "details" : {
    "database" : "H2",
    "validationQuery" : "isValid()"
  }
}

响应结构

响应包含应用程序运行状况的特定组件的运行状况的详细信息。 下表描述了响应的结构:Spring中文文档

路径 类型 描述

statusSpring中文文档

StringSpring中文文档

应用程序特定部分的状态Spring中文文档

detailsSpring中文文档

ObjectSpring中文文档

应用程序特定部分的运行状况的详细信息。Spring中文文档

路径 类型 描述

statusSpring中文文档

StringSpring中文文档

应用程序特定部分的状态Spring中文文档

detailsSpring中文文档

ObjectSpring中文文档

应用程序特定部分的运行状况的详细信息。Spring中文文档

检索嵌套组件的运行状况

如果特定组件包含其他嵌套组件(如上例中的指示器),则可以通过向 发出请求来检索此类嵌套组件的运行状况,如以下基于 curl 的示例所示:brokerGET/actuator/health/{component}/{subcomponent}Spring中文文档

$ curl 'http://localhost:8080/actuator/health/broker/us1' -i -X GET \
    -H 'Accept: application/json'

生成的响应类似于以下内容:Spring中文文档

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 66

{
  "status" : "UP",
  "details" : {
    "version" : "1.0.2"
  }
}

应用程序运行状况的组件可以任意深度嵌套,具体取决于应用程序的运行状况指示器及其分组方式。 运行状况终结点支持 URL 中任意数量的标识符,以允许检索任何深度的组件的运行状况。/{component}Spring中文文档

响应结构

响应包含应用程序特定组件的实例运行状况的详细信息。 下表描述了响应的结构:Spring中文文档

路径 类型 描述

statusSpring中文文档

StringSpring中文文档

应用程序特定部分的状态Spring中文文档

detailsSpring中文文档

ObjectSpring中文文档

应用程序特定部分的运行状况的详细信息。Spring中文文档

路径 类型 描述

statusSpring中文文档

StringSpring中文文档

应用程序特定部分的状态Spring中文文档

detailsSpring中文文档

ObjectSpring中文文档

应用程序特定部分的运行状况的详细信息。Spring中文文档