
# 查询健康检查列表 - ListHealthMonitors
#### 功能介绍
查询健康检查。支持过滤查询和分页查询。如未特殊说明，匹配规则为精确匹配。
#### 调试
您可以在[API Explorer](https://apiexplorer.developer.huaweicloud.com/apiexplorer/doc?product=ELB&api=ListHealthmonitors&version=v2)中直接运行调试该接口。
#### URI
GET /v2/{project_id}/elb/healthmonitors
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                                                   |
|:---|:---|:---|:---|
| project_id | 是    | String | 操作用户的项目ID。 获取方法详见[获取项目ID](https://support.huaweicloud.com/api-elb/elb_fl_0008.html)。 |
   
表2查询参数 
| 参数             | 是否必选 | 参数类型    | 描述                                                                                                                                                                                                                                                                                                                                                                                                                      |
|:---|:---|:---|:---|
| marker         | 否    | String  | 分页查询的起始的资源ID，表示上一页最后一条查询记录的健康检查的ID。 必须与limit一起使用。                                                                                                                                                                                                                                                                                                                       |
| limit          | 否    | Integer | 分页查询每页的健康检查个数。如果不设置，则默认不分页查询所有。                                                                                                                                                                                                                                                                                                                                                                                         |
| page_reverse   | 否    | Boolean | 分页的顺序，true表示从后往前分页，false表示从前往后分页，默认为false。 必须与limit一起使用。                                                                                                                                                                                                                                                                                                               |
| id             | 否    | String  | 健康检查ID。                                                                                                                                                                                                                                                                                                                                                                                                                 |
| tenant_id      | 否    | String  | 健康检查所在的项目ID。 支持的最大字符长度：255                                                                                                                                                                                                                                                                                                                                                   |
| project_id     | 否    | String  | 此参数和tenant_id参数含义一样，均指健康检查所在的项目ID。                                                                                                                                                                                                                                                                                                                                                                                      |
| name           | 否    | String  | 健康检查名称。 支持的最大字符长度：255                                                                                                                                                                                                                                                                                                                                                  |
| delay          | 否    | Integer | 健康检查间隔，单位秒，取值范围\[1，50\]。                                                                                                                                                                                                                                                                                                                                                                                                |
| max_retries    | 否    | Integer | 健康检查连续成功多少次后，将后端服务器的健康检查状态由OFFLINE判定为ONLINE，取值范围\[1，10\]。                                                                                                                                                                                                                                                                                                                                                               |
| admin_state_up | 否    | Boolean | 健康检查的管理状态。 取值范围：true/false。默认为true； - true表示开启健康检查；  - false表示关闭健康检查。             |
| timeout        | 否    | Integer | 健康检查超时时间，单位秒，取值范围\[1，50\]。 说明： 建议该值小于delay的值。                                                                                                                                                                                                                                                                               |
| type           | 否    | String  | 健康检查协议的类型。 取值范围：TCP、UDP_CONNECT、HTTP。                                                                                                                                                                                                                                                                                                                                     |
| monitor_port   | 否    | Integer | 健康检查端口号。 默认为空，表示使用后端云服务器的protocol_port作为健康检查的检查端口。                                                                                                                                                                                                                                                                                                                     |
| expected_codes | 否    | String  | 期望HTTP响应状态码，指定下列值： 单值，例如200； 列表，例如200，202； 区间，例如200-204。 仅当type为HTTP时生效。 支持的最大字符长度：64 说明： 该字段为预留字段，暂未启用。 |
| domain_name    | 否    | String  | 健康检查时，发送的http请求的域名。 仅当type为HTTP时生效。 默认为空，表示使用负载均衡器的vip_address作为http请求的目的地址。 以数字或字母开头，只能包含数字、字母、'-'、'.'。 例如：www.test.com 支持的最大字符长度：100                             |
| url_path       | 否    | String  | 健康检查时发送的http请求路径。默认为"/"。 以"/"开头。 仅当type为HTTP时生效。 例如："/test" 支持的最大字符长度：80                                                                                                                                                     |
| http_method    | 否    | String  | HTTP请求的方法；默认值：GET 取值范围：GET、HEAD、POST、PUT、DELETE、TRACE、OPTIONS、CONNECT、PATCH。 仅当type为HTTP时生效。 说明： 该字段为预留字段，暂未启用。                                                                                                           |
   
#### 请求消息
无
#### 响应消息
表3响应参数 
| 参数             | 参数类型                                                                                 | 描述                                                                          |
|:---|:---|:---|
| healthmonitors | Array of [Healthmonitors] objects | 健康检查对象列表。列表元素数据结构详见[表4]。 |
   
 表4healthmonitor字段说明 
| 参数               | 参数类型                                                                                                                   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|
| id               | String                                                                                                                 | 健康检查ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| tenant_id        | String                                                                                                                 | 健康检查所在的项目ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| project_id       | String                                                                                                                 | 此参数和tenant_id参数含义一样，均指健康检查所在的项目ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| name             | String                                                                                                                 | 健康检查名称。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| delay            | Integer                                                                                                                | 健康检查间隔，单位秒，取值范围\[1，50\]。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| max_retries      | Integer                                                                                                                | 健康检查最大重试次数，取值范围\[1，10\]。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| max_retries_down | Integer                                                                                                                | 健康检查连续失败多少次后，将后端服务器的健康检查状态由ONLINE判定为OFFLINE，取值范围\[1，10\]。                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| pools            | Array of [Pools](https://support.huaweicloud.com/api-elb/elb_qy_jk_0001.html#elb_qy_jk_0001__table20995524304) objects | 健康检查关联的后端云服务器组的ID列表。详见[表6](https://support.huaweicloud.com/api-elb/elb_qy_jk_0001.html#elb_qy_jk_0001__table20995524304)                                                                                                                                                                                                                                                                                                                                                                                                            |
| admin_state_up   | Boolean                                                                                                                | 健康检查的管理状态。 该字段为预留字段，暂未启用。取值范围：true/false。 - true表示开启。  - false表示关闭。   |
| timeout          | Integer                                                                                                                | 健康检查超时时间，单位秒，取值范围\[1，50\]。 说明： 建议该值小于delay的值。                                                                                                                                                                                                                                                                                                                                                             |
| type             | String                                                                                                                 | 健康检查协议的类型。 取值范围：TCP、UDP_CONNECT、HTTP。                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| monitor_port     | Integer                                                                                                                | 健康检查端口号，取值范围\[1，65535\]。 默认为空，表示使用后端云服务器的protocol_port作为健康检查的检查端口。                                                                                                                                                                                                                                                                                                                                                                                                  |
| expected_codes   | String                                                                                                                 | 期望HTTP响应状态码，指定下列值： 单值，例如200； 列表，例如200，202； 区间，例如200-204。 仅当type为HTTP时生效。 暂时不支持该字段，统一置为200。                                                                                                                                            |
| domain_name      | String                                                                                                                 | 健康检查时，发送的http请求的域名。 仅当type为HTTP时生效。 默认为空，表示使用负载均衡器的vip_address作为http请求的目的地址。 以数字或字母开头，只能包含数字、字母、'-'、'.'。 例如：www.test.com                                                                                                                                            |
| url_path         | String                                                                                                                 | 健康检查时发送的http请求路径。默认为"/"。 以"/"开头。 仅当type为HTTP时生效。 例如："/test"                                                                                                                                                                                                                                                                                 |
| http_method      | String                                                                                                                 | HTTP请求的方法；默认值：GET 取值范围：GET、HEAD、POST、PUT、DELETE、TRACE、OPTIONS、CONNECT、PATCH。 仅当type为HTTP时生效。 说明： 该字段为预留字段，暂未启用。                                                                                                                                                           |
   
表5pools字段说明 
| 参数 | 是否必选 | 参数类型   | 描述       |
|:---|:---|:---|:---|
| id | 是    | String | 后端服务器组id |
   
#### 请求示例
- 请求样例1 全量查询健康检查
  ```
  GET https://{Endpoint}/v2/601240b9c5c94059b63d484c92cfe308/elb/healthmonitors
  ```
  
- 请求样例2 过滤查询类型为HTTP的健康检查
  ```
  GET https://{Endpoint}/v2/601240b9c5c94059b63d484c92cfe308/elb/healthmonitors?type=HTTP
  ```
  
 
#### 响应示例
- 响应样例1
  ```
  {
      "healthmonitors": [
          {
              "monitor_port": null,
              "name": "",
              "admin_state_up": true,
              "tenant_id": "601240b9c5c94059b63d484c92cfe308",
              "project_id": "601240b9c5c94059b63d484c92cfe308", 
              "domain_name": null,
              "delay": 5,
              "expected_codes": "200",
              "max_retries": 3,
              "max_retries_down": 5,
              "http_method": "GET",
              "timeout": 3,
              "pools": [
                  {
                      "id": "caef8316-6b65-4676-8293-cf41fb63cc2a"
                  }
              ],
              "url_path": "/",
              "type": "HTTP",
              "id": "1b587819-d619-49c1-9101-fe72d8b361ef"
          }
      ]
  }
  ```
  
- 响应样例2
  ```
  {
      "healthmonitors": [
          {
              "monitor_port": null,
              "name": "",
              "admin_state_up": true,
              "tenant_id": "601240b9c5c94059b63d484c92cfe308",
              "project_id": "601240b9c5c94059b63d484c92cfe308", 
              "domain_name": null,
              "delay": 5,
              "expected_codes": "200",
              "max_retries": 3,
              "max_retries_down": 5,
              "http_method": "GET",
              "timeout": 3,
              "pools": [
                  {
                      "id": "caef8316-6b65-4676-8293-cf41fb63cc2a"
                  }
              ],
              "url_path": "/",
              "type": "HTTP",
              "id": "1b587819-d619-49c1-9101-fe72d8b361ef"
          }
      ]
  }
  ```
  
 
#### 返回码
请参见[状态码](https://support.huaweicloud.com/api-elb/elb_gc_1102.html)。
