All Products
Search
Document Center

Server Load Balancer:ListServerGroups

Last Updated:Oct 31, 2024

Queries the server groups of a Network Load Balancer (NLB) instance.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
nlb:ListServerGroupsget
  • ServerGroup
    acs:nlb:{#regionId}:{#accountId}:servergroup/*
  • ServerGroup
    acs:nlb:{#regionId}:{#accountId}:servergroup/{#ServerGroupId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ServerGroupIdsarrayNo

The server group ID. You can specify up to 20 server group IDs in each call.

ServerGroupIdstringNo

The server group ID. You can specify up to 20 server group IDs in each call.

sgp-atstuj3rtoptyui****
ServerGroupNamesarrayNo

The names of the server groups to be queried. You can specify up to 20 names in each call.

ServerGroupNamestringNo

The names of the server groups to be queried. You can specify up to 20 names in each call.

NLB_ServerGroup
ResourceGroupIdstringNo

The ID of the resource group to which the server group belongs.

rg-atstuj3rtop****
ServerGroupTypestringNo

The type of server group. Valid values:

  • Instance : allows you to add servers of the Ecs, Ens, and Eci types.
  • Ip: allows you to add servers by specifying IP addresses.
Instance
VpcIdstringNo

The ID of the virtual private cloud (VPC) to which the server group belongs.

vpc-bp15zckdt37pq72zv****
Tagarray<object>No

The tags.

objectNo

The tags.

KeystringNo

The key of the tag. You can specify up to 10 tag keys.

The tag key can be up to 64 characters in length, and cannot contain http:// or https://. It cannot start with aliyun or acs:.

Test
ValuestringNo

The value of the tag. You can specify up to 10 tag values.

The tag value can be up to 128 characters in length, and cannot contain http:// or https://. It cannot start with aliyun or acs:.

Test
NextTokenstringNo

The pagination token that is used in the next request to retrieve a new page of results. Valid values:

  • You do not need to specify this parameter for the first request.
  • You must specify the token that is obtained from the previous query as the value of NextToken.
FFmyTO70tTpLG6I3FmYAXGKPd****
MaxResultsintegerNo

The number of entries per page. Valid values: 1 to 100. Default value: 20.

20
RegionIdstringNo

The region ID of the NLB instance.

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou

Response parameters

ParameterTypeDescriptionExample
object

The operation to query server groups.

RequestIdstring

The request ID.

54B28E3D-DF70-471B-AA93-08E683A1B45
ServerGroupsarray<object>

A list of server groups.

ServerGroupobject

The configurations of the server group.

RegionIdstring

The region ID of the NLB instance.

cn-hangzhou
ServerGroupIdstring

The server group ID.

sgp-atstuj3rtoptyui****
ServerGroupNamestring

The server group name.

NLB_ServerGroup
ServerGroupTypestring

The type of server group. Valid values:

  • Instance : contains servers of the Ecs, Ens, and Eci types.
  • Ip: contains servers specified by IP addresses.
Instance
AddressIPVersionstring

The IP version. Valid values:

  • ipv4
  • DualStack
ipv4
VpcIdstring

The ID of the VPC to which the server group belongs.

vpc-bp15zckdt37pq72zv****
Schedulerstring

The routing algorithm. Valid values:

  • Wrr: Backend servers with higher weights receive more requests than backend servers with lower weights.
  • rr: Requests are forwarded to the backend servers in sequence. sch: Requests are forwarded to the backend servers based on source IP address hashing.
  • sch: Requests from the same source IP address are forwarded to the same backend server.
  • tch: Four-element hashing, which specifies consistent hashing that is based on four factors: source IP address, destination IP address, source port, and destination port. Requests that contain the same information based on the four factors are forwarded to the same backend server.
  • qch: QUIC ID hashing. Requests that contain the same QUIC ID are forwarded to the same backend server.
Wrr
Protocolstring

The backend protocol. Valid values: TCP and UDP.

TCP
HealthCheckobject

The configurations of health checks.

HealthCheckEnabledboolean

Indicates whether the health check feature is enabled. Valid values:

  • true
  • false
false
HealthCheckTypestring

The protocol that is used for health checks. Valid values:

  • TCP
  • HTTP
  • UDP
TCP
HealthCheckConnectPortinteger

The backend port that is used for health checks.

Valid values: 0 to 65535.

A value of 0 indicates that the port on a backend server is used for health checks.

200
HealthyThresholdinteger

The number of times that an unhealthy backend server must consecutively pass health checks before it is declared healthy. In this case, the health status changes from fail to success.

Valid values: 2 to 10.

2
UnhealthyThresholdinteger

The number of times that a healthy backend server must consecutively fail health checks before it is declared unhealthy. In this case, the health status changes from success to fail.

Valid values: 2 to 10.

3
HealthCheckConnectTimeoutinteger

The maximum timeout period of a health check. Unit: seconds. Valid values: 1 to 300.

200
HealthCheckIntervalinteger

The interval at which health checks are performed. Unit: seconds.

Valid values: 5 to 50.

200
HealthCheckDomainstring

The domain name that you want to use for health checks. Valid values:

  • $SERVER_IP: the private IP address of a backend server.
  • domain: a specified domain name. The domain name must be 1 to 80 characters in length, and can contain lowercase letters, digits, hyphens (-), and periods (.).
Note This parameter takes effect only when HealthCheckType is set to HTTP.
$SERVER_IP
HealthCheckUrlstring

The path to which health check probes are sent.

Note This parameter takes effect only when HealthCheckType is set to HTTP.
/test/index.html
HealthCheckHttpCodearray

The HTTP status codes returned for health checks. Multiple HTTP status codes are separated by commas (,). Valid values: http_2xx, http_3xx, http_4xx, and http_5xx.

Note This parameter takes effect only when HealthCheckType is set to HTTP.
HealthCheckHttpCodestring

The HTTP status codes returned for health checks. Multiple HTTP status codes are separated by commas (,). Valid values: http_2xx, http_3xx, http_4xx, and http_5xx.

Note This parameter takes effect only when HealthCheckType is set to HTTP.
http_2xx
HttpCheckMethodstring

The HTTP method that is used for health checks. Valid values: GET and HEAD.

Note This parameter takes effect only when HealthCheckType is set to HTTP.
GET
HealthCheckReqstring

The request string of UDP health checks. The string must be 1 to 64 characters in length, and can contain letters and digits.

hello
HealthCheckExpstring

The response string of UDP health checks. The string must be 1 to 64 characters in length, and can contain letters and digits.

ok
ConnectionDrainEnabledboolean

Indicates whether connection draining is enabled. Valid values:

  • true
  • false
false
ConnectionDrainTimeoutinteger

The timeout period of connection draining. Unit: seconds. Valid values: 10 to 900.

200
PreserveClientIpEnabledboolean

Indicates whether client IP preservation is enabled. Valid values:

  • true
  • false
Note This parameter is set to true by default when AddressIPVersion is set to ipv4. This parameter is set to false when AddressIPVersion is set to ipv6. true will be supported by later versions.
true
AnyPortEnabledboolean

Indicates whether the feature of forwarding requests to all ports is enabled. Valid values:

  • true
  • false
false
ResourceGroupIdstring

The ID of the resource group to which the server group belongs.

rg-atstuj3rtop****
ServerGroupStatusstring

The status of the server group. Valid values:

  • Creating
  • Available
  • Configuring
Available
AliUidlong

The ID of the Alibaba Cloud account.

165820696622****
Tagsarray<object>

The tag.

Tagobject

The tags.

Keystring

The tag key. At most 10 tag keys are returned.

The tag key can be up to 64 characters in length, and cannot contain http:// or https://. It cannot start with aliyun or acs:.

Test
Valuestring

The tag value. At most 10 tag values are returned.

The tag value can be up to 128 characters in length, and cannot contain http:// or https://. It cannot start with aliyun or acs:.

Test
RelatedLoadBalancerIdsarray

The NLB instances.

LoadbalancerIdstring

A list of NLB instances.

nlb-83ckzc8d4xlp8o****
ServerCountinteger

The number of server groups associated with the NLB instances.

2
TotalCountinteger

The total number of entries returned.

1
NextTokenstring

A pagination token. It can be used in the next request to retrieve a new page of results. Valid values:

  • If NextToken is empty, no next page exists.
  • If a value is returned for NextToken, the value is the token that determines the start point of the next query.
FFmyTO70tTpLG6I3FmYAXGKPd****
MaxResultsinteger

The number of entries per page. Valid values: 1 to 100.

20

Examples

Sample success responses

JSONformat

{
  "RequestId": "54B28E3D-DF70-471B-AA93-08E683A1B45",
  "ServerGroups": [
    {
      "RegionId": "cn-hangzhou",
      "ServerGroupId": "sgp-atstuj3rtoptyui****",
      "ServerGroupName": "NLB_ServerGroup",
      "ServerGroupType": "Instance",
      "AddressIPVersion": "ipv4",
      "VpcId": "vpc-bp15zckdt37pq72zv****",
      "Scheduler": "Wrr",
      "Protocol": "TCP",
      "HealthCheck": {
        "HealthCheckEnabled": false,
        "HealthCheckType": "TCP",
        "HealthCheckConnectPort": 200,
        "HealthyThreshold": 2,
        "UnhealthyThreshold": 3,
        "HealthCheckConnectTimeout": 200,
        "HealthCheckInterval": 200,
        "HealthCheckDomain": "$SERVER_IP",
        "HealthCheckUrl": "/test/index.html",
        "HealthCheckHttpCode": [
          "http_2xx"
        ],
        "HttpCheckMethod": "GET",
        "HealthCheckReq": "hello",
        "HealthCheckExp": "ok"
      },
      "ConnectionDrainEnabled": false,
      "ConnectionDrainTimeout": 200,
      "PreserveClientIpEnabled": true,
      "AnyPortEnabled": false,
      "ResourceGroupId": "rg-atstuj3rtop****",
      "ServerGroupStatus": "Available",
      "AliUid": 0,
      "Tags": [
        {
          "Key": "Test",
          "Value": "Test"
        }
      ],
      "RelatedLoadBalancerIds": [
        "nlb-83ckzc8d4xlp8o****"
      ],
      "ServerCount": 2
    }
  ],
  "TotalCount": 1,
  "NextToken": "FFmyTO70tTpLG6I3FmYAXGKPd****",
  "MaxResults": 20
}

Error codes

HTTP status codeError codeError messageDescription
400SystemBusySystem is busy, please try again later.-
403Forbidden.%sAuthentication is failed for %s.-
403Forbidden.NoPermissionAuthentication is failed for NoPermission.Authentication is failed for NoPermission.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-06-25The Error code has changed. The response structure of the API has changedView Change Details
2023-09-27The Error code has changed. The response structure of the API has changedView Change Details
2023-09-26The Error code has changedView Change Details
2023-09-18The Error code has changed. The response structure of the API has changedView Change Details
2023-08-22The Error code has changedView Change Details