更新时间:2023-12-18 GMT+08:00

查询后端ECS的实例ID

操作场景

本章节通过示例演示如何调用API来获取负载均衡器下的Member对应的ECS的ID。

前提条件

已创建负载均衡器、后端服务器组和后端服务器。

操作步骤

发送“GET /v3/{project_id}/elb/members”,project_id为项目ID,其他查询条件根据实际使用情况添加,具体可以参考API文档。在Request Header中增加“X-Auth-Token”。

查看请求响应结果,从响应字段中的instance_id获取ECS ID。
  • 请求成功时,响应参数如下:
    {
        "request_id": "0df89f0ad2ecf0e0a5688978d28e9a6d",
        "members": [
            {
                "weight": 1,
                "admin_state_up": true,
                "project_id": "04dd36f9c0000fe22f9fc00b409f1sq1",
                "address": "192.168.2.96",
                "protocol_port": 80,
                "id": "0b7c1e58-5940-41c1-a7c5-dbe4b3f23e4w",
                "operating_status": ONLINE,
                "status": [
                    {
                        "listener_id": "73bea9d6-fb7f-47cc-b949-c3382abb1f46",
                        "operating_status": "ONLINE"
                    }
                ],
                "instance_id": "6985a0dc-5884-40f2-9426-15fb4bab8f1d", // ECS ID
                "device_id": "6985a0dc-5884-40f2-9426-15fb4bab8f1d",
                "device_owner": "compute:az1",
                "member_type": "instance",
                "created_at": "2023-05-15T07:15:43Z",
                "updated_at": "2023-05-15T07:15:53Z",
                "loadbalancer_id": "955af176-4275-49ac-b47e-05912x9dj33c",
                "loadbalancers": [
                    {
                        "id": "955af176-4275-49ac-b47e-05912x9dj33c"
                    }
                ],
                "pool_id": "b6e6fdcf-4f4d-4d21-95ca-925143af6de8",
                "ip_version": "v4",
                "subnet_cidr_id": "b765590e-905e-4e13-9d34-0e0ea9de2k9d"
            }
        ],
        "page_info": {
            "previous_marker": "0b7c1e58-5940-41c1-a7c5-dbe4b3f83506",
            "current_count": 1
        }
    }
  • 请求异常时,错误码请参见 错误码