ListServerGroups

更新时间:
复制 MD 格式

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

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

nlb:ListServerGroups

get

ServerGroup

acs:nlb:{#regionId}:{#accountId}:servergroup/*

ServerGroup

acs:nlb:{#regionId}:{#accountId}:servergroup/{#ServerGroupId}

None None

Request parameters

Parameter

Type

Required

Description

Example

ServerGroupIds

array

No

The IDs of the server groups. You can specify up to 20 server group IDs in each call.

string

No

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

sgp-atstuj3rtoptyui****

ServerGroupNames

array

No

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

string

No

The name of the server group. You can specify up to 20 server group names in each call.

NLB_ServerGroup

ResourceGroupId

string

No

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

rg-atstuj3rtop****

ServerGroupType

string

No

The type of the server group. Valid values:

  • Instance: an instance-type server group. You can add Elastic Compute Service (ECS) instances, Edge Node Service (ENS) instances, and Elastic Container Instance (ECI) instances to this type of server group.

  • Ip: an IP-type server group. You can add IP addresses to this type of server group.

Instance

VpcId

string

No

The ID of the VPC in which the server group is deployed.

vpc-bp15zckdt37pq72zv****

Tag

array<object>

No

The tags.

object

No

The tag.

Key

string

No

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

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

Test

Value

string

No

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

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

Test

NextToken

string

No

The token that is used to retrieve the next page of results.

  • Leave this parameter empty for the first request.

  • For subsequent requests, set this parameter to the value of NextToken from the previous response.

FFmyTO70tTpLG6I3FmYAXGKPd****

MaxResults

integer

No

The number of entries to return on each page. Valid values: 1 to 100. Default value: 20.

20

RegionId

string

No

The ID of the region where the NLB instance is deployed.

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

cn-hangzhou

Response elements

Element

Type

Description

Example

object

A list of server groups.

RequestId

string

The request ID.

54B28E3D-DF70-471B-AA93-08E683A1B45

ServerGroups

array<object>

The list of backend server groups.

array<object>

An array of backend server groups.

RegionId

string

The ID of the region where the NLB instance is deployed.

cn-hangzhou

ServerGroupId

string

The server group ID.

sgp-atstuj3rtoptyui****

ServerGroupName

string

The server group name.

NLB_ServerGroup

ServerGroupType

string

The type of the server group. Valid values:

  • Instance: an instance-type server group. You can add ECS instances, ENS instances, and ECI instances to this type of server group.

  • Ip: an IP-type server group. You can add IP addresses to this type of server group.

Instance

AddressIPVersion

string

The IP version. Valid values:

  • Ipv4: IPv4.

  • DualStack: dual-stack.

ipv4

VpcId

string

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

vpc-bp15zckdt37pq72zv****

Scheduler

string

The scheduling algorithm. Valid values:

  • Wrr: weighted round-robin. Backend servers with higher weights receive more requests.

  • Wlc: weighted least connections. In addition to the weight of each backend server, the system also considers the number of connections to each backend server. Requests are distributed to the backend server with the least number of connections. If multiple backend servers have the same number of connections, requests are distributed to the backend server with the highest weight.

  • rr: round-robin. Requests are distributed to backend servers in sequence.

  • sch: source IP hash. Requests from the same source IP address are distributed to the same backend server.

  • tch: four-tuple hash. Requests are distributed to backend servers based on a hash of the four-tuple (source IP address, destination IP address, source port, and destination port). This ensures that requests from the same session are sent to the same backend server.

  • qch: QUIC ID hash. Requests that have the same QUIC ID are sent to the same backend server.

Wrr

Protocol

string

The backend protocol. Valid values: TCP and UDP.

TCP

HealthCheck

object

The health check configuration.

HealthCheckEnabled

boolean

Indicates whether health checks are enabled. Valid values:

  • true

  • false

false

HealthCheckType

string

The health check protocol. Valid values:

  • TCP

  • HTTP

  • UDP

TCP

HealthCheckConnectPort

integer

The port that is used for health checks.

Valid values: 0 to 65535.

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

200

HealthyThreshold

integer

The number of consecutive health checks that a backend server must pass to be considered healthy. The health check status changes from failed to success.

Valid values: 2 to 10.

2

UnhealthyThreshold

integer

The number of consecutive health checks that a backend server must fail to be considered unhealthy. The health check status changes from success to failed.

Valid values: 2 to 10.

3

HealthCheckConnectTimeout

integer

The maximum timeout period of a health check response. Unit: seconds. Default value: 5.

Valid values: 1 to 300.

200

HealthCheckInterval

integer

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

  • If HealthCheckType is set to TCP or HTTP, the value must be in the range of 1 to 50.

  • If HealthCheckType is set to UDP, the value must be in the range of 1 to 300. Ensure that the interval is greater than or equal to the response timeout period to prevent timeout issues.

10

HealthCheckDomain

string

The domain name that is used for health checks. Valid values:

  • $SERVER_IP: the private IP address of a backend server.

  • domain: a specific 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

HealthCheckUrl

string

The path to which health check probes are sent.

Note

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

/test/index.html

HealthCheckHttpCode

array

The HTTP status codes that indicate a healthy state. You can specify multiple HTTP status codes. Separate them with commas (,). Valid values: http_2xx, http_3xx, http_4xx, and http_5xx.

Note

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

string

The HTTP status codes that indicate a healthy state. You can specify multiple HTTP status codes. Separate them with 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

HttpCheckMethod

string

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

HealthCheckReq

string

The request string for UDP health checks. The string can contain only letters and digits and must be up to 512 characters in length.

hello

HealthCheckExp

string

The response string for UDP health checks. The string can contain only letters and digits and must be up to 512 characters in length.

ok

HealthCheckHttpVersion

string

The version of the HTTP protocol. Valid values: HTTP1.0 and HTTP1.1.

Note

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

HTTP1.0

ConnectionDrainEnabled

boolean

Indicates whether connection draining is enabled. Valid values:

  • true

  • false

false

ConnectionDrainTimeout

integer

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

200

PreserveClientIpEnabled

boolean

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 can only be set to false when AddressIPVersion is set to ipv6. Support for setting this parameter to true for ipv6 will be available in later releases.

true

AnyPortEnabled

boolean

Indicates whether all-port forwarding is enabled. Valid values:

  • true

  • false

false

ResourceGroupId

string

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

rg-atstuj3rtop****

ServerGroupStatus

string

The status of the server group. Valid values:

  • Creating

  • Available

  • Configuring

Available

AliUid

integer

The Alibaba Cloud account ID.

165820696622****

Tags

array<object>

The tags.

object

The tag.

Key

string

The tag key. Up to 10 tag keys are returned.

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

Test

Value

string

The tag value. Up to 10 tag values are returned.

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

Test

RelatedLoadBalancerIds

array

A list of NLB instances.

string

A list of Network Load Balancer (NLB) instances.

nlb-83ckzc8d4xlp8o****

ServerCount

integer

The number of backend servers.

2

IpVersionAffinityMode

string

The traffic scheduling policy for a dual-stack server group:

  • NonAffinity (default): Traffic is distributed to all healthy backend servers based on the scheduling algorithm, regardless of the IP version of the source IP address.

  • Affinity: Traffic is distributed based on the IP version of the source IP address. IPv4 requests are forwarded only to IPv4 backend servers, and IPv6 requests are forwarded only to IPv6 backend servers.

Note

This parameter takes effect only when AddressIPVersion is set to DualStack.

Affinity

TotalCount

integer

The total number of entries returned.

1

NextToken

string

The token that is used to retrieve the next page of results.

  • If this parameter is empty, all results are returned.

  • If a value is returned for this parameter, the value is the token that is used to retrieve the next page of results.

FFmyTO70tTpLG6I3FmYAXGKPd****

MaxResults

integer

The number of entries returned on each page. Valid values: 1 to 100.

20

Examples

Success response

JSON format

{
  "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": 10,
        "HealthCheckDomain": "$SERVER_IP",
        "HealthCheckUrl": "/test/index.html",
        "HealthCheckHttpCode": [
          "http_2xx"
        ],
        "HttpCheckMethod": "GET",
        "HealthCheckReq": "hello",
        "HealthCheckExp": "ok",
        "HealthCheckHttpVersion": "HTTP1.0"
      },
      "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,
      "IpVersionAffinityMode": "Affinity"
    }
  ],
  "TotalCount": 1,
  "NextToken": "FFmyTO70tTpLG6I3FmYAXGKPd****",
  "MaxResults": 20
}

Error codes

HTTP status code

Error code

Error message

Description

400 SystemBusy System is busy, please try again later.
403 Forbidden.%s Authentication is failed for %s.
403 Forbidden.NoPermission Authentication is failed for NoPermission. Authentication is failed for NoPermission.

See for a complete list.

Release notes

See Release Notes for a complete list.