Help Center/ Elastic Load Balance/ API Reference/ Examples/ Querying the ID of an ECS Used as a Backend Server
Updated on 2023-12-18 GMT+08:00

Querying the ID of an ECS Used as a Backend Server

Scenarios

Call APIs to obtain the ID of an ECS used as a backend server of a load balancer.

Prerequisites

You have created a load balancer, a backend server group, and a backend server.

Procedure

Send GET /v3/{project_id}/elb/members. project_id indicates the project ID. You can add other criteria as you needed. For details, see the API document. Add X-Auth-Token to the request header.

View the response result and obtain the ECS ID from instance_id.
  • The request is successful if the following response is displayed:
    {
        "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
        }
    }
  • If the request is abnormal, locate the fault by referring to Error Codes.