更新时间:2025-08-26 GMT+08:00
分享

查询健康检查列表

功能介绍

健康检查列表。

接口约束

  • 分页查询使用的参数为marker、limit、page_reverse。

  • marker和page_reverse只有和limit一起使用时才会生效,单独使用无效。

调用方法

请参见如何调用API

URI

GET /v3/{project_id}/elb/healthmonitors

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释:项目ID。获取方式请参见获取项目ID

约束限制:不涉及

取值范围:长度为32个字符,由小写字母和数字组成。

默认取值:不涉及

表2 Query参数

参数

是否必选

参数类型

描述

marker

String

参数解释:上一页最后一条记录的ID。

约束限制

  • 必须与limit一起使用。

  • 不指定时表示查询第一页。

  • 该字段不允许为空或无效的ID。

取值范围:不涉及

默认取值:不涉及

limit

Integer

参数解释:每页返回的个数。

约束限制:不涉及

取值范围:0-2000

默认取值:2000

page_reverse

Boolean

参数解释:是否反向查询。

约束限制

  • 必须与limit一起使用。

  • 当page_reverse=true时,若要查询上一页,marker取值为当前页返回值的previous_marker。

取值范围

  • true:查询上一页。

  • false:查询下一页。

默认取值:false

id

Array of strings

参数解释:健康检查ID。

支持多值查询,查询条件格式:id=xxx&id=xxx***。

约束限制:不涉及

取值范围:不涉及

默认取值:不涉及

monitor_port

Array of integers

参数解释:健康检查端口号。

支持多值查询,查询条件格式:monitor_port=xxx&monitor_port=xxx

约束限制:不涉及

取值范围:不涉及

默认取值:不涉及

domain_name

Array of strings

参数解释:发送健康检查请求的域名。

支持多值查询,查询条件格式:domain_name=xxx&domain_name=xxx

约束限制:不涉及

取值范围:以数字或字母开头,只能包含数字、字母、’-’、’.’。

默认取值:不涉及

name

Array of strings

参数解释:健康检查名称。

支持多值查询,查询条件格式:name=xxx&name=xxx

约束限制:不涉及

取值范围:不涉及

默认取值:不涉及

delay

Array of integers

参数解释:健康检查间隔。

支持多值查询,查询条件格式:delay=xxx&delay=xxx

约束限制:不涉及

取值范围:1-50,单位:秒。

默认取值:不涉及

max_retries

Array of integers

参数解释:健康检查连续成功多少次后,将后端服务器的健康检查状态由OFFLINE判定为ONLINE。

支持多值查询,查询条件格式:max_retries=xxx&max_retries=xxx

约束限制:不涉及

取值范围:1-10

默认取值:不涉及

admin_state_up

Boolean

参数解释:健康检查的管理状态。

约束限制:不涉及

取值范围

  • true:表示开启健康检查。

  • false表示关闭健康检查。

默认取值:不涉及

max_retries_down

Array of integers

参数解释:健康检查连续失败多少次后,将后端服务器的健康检查状态由ONLINE判定为OFFLINE。

支持多值查询,查询条件格式:max_retries_down=xxx&max_retries_down=xxx

约束限制:不涉及

取值范围:1-10

默认取值:不涉及

timeout

Integer

参数解释:一次健康检查请求的超时时间。

约束限制:不涉及

取值范围:不涉及

默认取值:不涉及

type

Array of strings

参数解释:健康检查请求协议。

支持多值查询,查询条件格式:type=xxx&type=xxx

约束限制:不涉及

取值范围:TCP、UDP_CONNECT、HTTP、HTTPS、TLS和GRPC。

默认取值:不涉及

expected_codes

Array of strings

参数解释:期望响应状态码。

支持多值查询,查询条件格式:expected_codes=xxx&expected_codes=xxx

约束限制

  • 单值:单个返回码,例如200。

  • 列表:多个特定返回码,例如200,202。

  • 区间:一个返回码区间,例如200-204。

取值范围:不涉及

默认取值:不涉及

url_path

Array of strings

参数解释:健康检查测试member健康时发送的http请求路径。

支持多值查询,查询条件格式:url_path=xxx&url_path=xxx

约束限制:不涉及

取值范围:不涉及

默认取值:不涉及

http_method

Array of strings

参数解释:HTTP请求方法。

支持多值查询,查询条件格式:http_method=xxx&http_method=xxx

约束限制:不涉及

取值范围:GET、HEAD、POST

默认取值:不涉及

enterprise_project_id

Array of strings

参数解释:资源所属的企业项目ID。

支持多值查询,查询条件格式:enterprise_project_id=xxx&enterprise_project_id=xxx

约束限制

  • 如果enterprise_project_id不传值,默认查询所有企业项目下的资源,鉴权按照细粒度权限鉴权,必须在用户组下分配elb:healthmonitors:list权限。

  • 如果enterprise_project_id传值,鉴权按照企业项目权限鉴权,分为传入具体eps_id和all_granted_eps两种场景,前者查询指定eps_id的eps下的资源,后者查询的是所有有list权限的eps下的资源。

取值范围:不涉及

默认取值:不涉及

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:IAM鉴权Token。

约束限制:不涉及

取值范围:不涉及

默认取值:不涉及

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

request_id

String

参数解释:请求ID。

取值范围:由数字、小写字母和中划线(-)组成的字符串,自动生成。

page_info

PageInfo object

参数解释:分页信息。

healthmonitors

Array of HealthMonitor objects

参数解释:健康检查对象。

表5 PageInfo

参数

参数类型

描述

previous_marker

String

参数解释:分页查询结果中第一条记录的ID。通常用于配合page_reverse=true查询上一页。

取值范围:不涉及

next_marker

String

参数解释:分页查询结果中最后一条记录的ID。通常用于查询下一页。

取值范围:不涉及

current_count

Integer

参数解释:当前页返回记录数。

取值范围:不涉及

表6 HealthMonitor

参数

参数类型

描述

admin_state_up

Boolean

健康检查的管理状态。

取值范围

  • true:表示开启健康检查。

  • false表示关闭健康检查。

delay

Integer

参数解释:健康检查间隔。

取值范围:1-50,单位:秒。

domain_name

String

参数解释:发送健康检查请求的域名。

取值范围:以数字或字母开头,只能包含数字、字母、’-’、’.’。

expected_codes

String

参数解释:期望响应状态码。

取值范围

  • 单值:单个返回码,例如200。

  • 列表:多个特定返回码,例如200,202。

  • 区间:一个返回码区间,例如200-204。

http_method

String

参数解释:HTTP请求方法。

取值范围:GET、HEAD、POST

id

String

参数解释:健康检查ID。

取值范围:不涉及

max_retries

Integer

参数解释:健康检查连续成功多少次后,将后端服务器的健康检查状态由OFFLINE判定为ONLINE。

取值范围:1-10

max_retries_down

Integer

参数解释:健康检查连续失败多少次后,将后端服务器的健康检查状态由ONLINE判定为OFFLINE。

取值范围:1-10

monitor_port

Integer

参数解释:健康检查端口号。

取值范围:1-65535和null,传null表示使用后端服务器端口号。

name

String

参数解释:健康检查名称。

取值范围:不涉及

pools

Array of PoolRef objects

参数解释:健康检查所在的后端服务器组ID列表。实际只会有一个后端服务器组ID。

取值范围:不涉及

project_id

String

参数解释:健康检查所在的项目ID。

取值范围:不涉及

timeout

Integer

参数解释:一次健康检查请求的超时时间。

取值范围:不涉及

type

String

参数解释: 健康检查请求协议。

取值范围:TCP、UDP_CONNECT、HTTP、HTTPS、TLS和GRPC。

url_path

String

参数解释:健康检查请求的请求路径。以"/"开头,默认为"/"。

取值范围:支持使用字母、数字和短划线(-)、正斜线(/)、半角句号(.)、百分号(%)、半角问号(?)、井号(#)和and(&)以及扩展字符集_;~!()*[]@$^:',+

created_at

String

参数解释:创建时间。

取值范围:yyyy-MM-dd'T'HH:mm:ss'Z',UTC时区。

注意:独享型实例的历史数据以及共享型实例下的资源,不返回该字段。

updated_at

String

参数解释: 更新时间。

取值范围:格式:yyyy-MM-dd'T'HH:mm:ss'Z',UTC时区。

注意:独享型实例的历史数据以及共享型实例下的资源,不返回该字段。

表7 PoolRef

参数

参数类型

描述

id

String

参数解释:后端服务器组ID。

取值范围:不涉及

请求示例

查询健康检查列表

GET https://{ELB_Endpoint}/v3/99a3fff0d03c428eac3678da6a7d0f24/elb/healthmonitors

响应示例

状态码:200

操作正常返回。

{
  "healthmonitors" : [ {
    "monitor_port" : null,
    "id" : "c2b210b2-60c4-449d-91e2-9e9ea1dd7441",
    "project_id" : "99a3fff0d03c428eac3678da6a7d0f24",
    "domain_name" : null,
    "name" : "My Healthmonitor update",
    "delay" : 10,
    "max_retries" : 10,
    "pools" : [ {
      "id" : "488acc50-6bcf-423d-8f0a-0f4184f5b8a0"
    } ],
    "admin_state_up" : true,
    "timeout" : 30,
    "type" : "HTTP",
    "expected_codes" : "200",
    "url_path" : "/",
    "http_method" : "GET"
  }, {
    "monitor_port" : null,
    "id" : "cda1af03-0660-4fd2-8edf-e38c79846e08",
    "project_id" : "99a3fff0d03c428eac3678da6a7d0f24",
    "domain_name" : "akik..un.com",
    "name" : "lijunqiu",
    "delay" : 50,
    "max_retries" : 1,
    "pools" : [ {
      "id" : "ae6e45ba-be84-4074-8ac6-bc4a56484809"
    } ],
    "admin_state_up" : false,
    "timeout" : 3,
    "type" : "UDP_CONNECT",
    "expected_codes" : null,
    "url_path" : "/world",
    "http_method" : null
  } ],
  "page_info" : {
    "next_marker" : "cda1af03-0660-4fd2-8edf-e38c79846e08",
    "previous_marker" : "c2b210b2-60c4-449d-91e2-9e9ea1dd7441",
    "current_count" : 2
  },
  "request_id" : "814bc40e-8b0a-4ced-b8e5-f136c3e1df6a"
}

SDK代码示例

SDK代码示例如下。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.elb.v3.region.ElbRegion;
import com.huaweicloud.sdk.elb.v3.*;
import com.huaweicloud.sdk.elb.v3.model.*;


public class ListHealthMonitorsSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        ElbClient client = ElbClient.newBuilder()
                .withCredential(auth)
                .withRegion(ElbRegion.valueOf("<YOUR REGION>"))
                .build();
        ListHealthMonitorsRequest request = new ListHealthMonitorsRequest();
        try {
            ListHealthMonitorsResponse response = client.listHealthMonitors(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkelb.v3.region.elb_region import ElbRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkelb.v3 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = ElbClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(ElbRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListHealthMonitorsRequest()
        response = client.list_health_monitors(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := elb.NewElbClient(
        elb.ElbClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListHealthMonitorsRequest{}
	response, err := client.ListHealthMonitors(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

操作正常返回。

错误码

请参见错误码

相关文档