Queries the server groups of an SLB instance.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes ListServerGroups

The operation that you want to perform. Set the value to ListServerGroups.

ServerGroupIds Array of String No sgp-atstuj3rtop****

The IDs of the server groups to be queried. You can specify up to 20 IDs at a time.

ServerGroupNames Array of String No Group3

The names of the server groups to be queried. You can specify up to 10 names at the same time.

ResourceGroupId String No rg-atstuj3rtop****

The ID of the resource group.

NextToken String No FFmyTO70tTpLG6I3FmYAXG****

The start position of the query. If this parameter is left empty, the query starts from the beginning.

MaxResults Integer No 50

The maximum number of data records to be queried. The parameter is optional. Valid values: 1 to 100. Default value: 20.

VpcId String No vpc-bp15zckdt37pq72zv****

The ID of the VPC that you want to access.

Response parameters

Parameter Type Example Description
MaxResults Integer 50

The maximum number of data records returned.

NextToken String caeba0bbb2be03f8****

The position where the query stopped. If the response does not contain this parameter, all data has been queried.

RequestId String CEF72CEB-54B6-4AE8-B225-F876FF7BA984

The ID of the request.

ServerGroups Array of ServerGroup

The server groups.

HealthCheckConfig Object

The configuration of health checks.

HealthCheckConnectPort Integer 80

The port of the backend server that is used for health checks.

Valid values: 0 to 65535.

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

HealthCheckEnabled Boolean true

Indicates whether health checks are enabled. Valid values:

  • true (default): Health checks are enabled.
  • false: Health checks are disabled.
HealthCheckHost String www.test.com

The domain name that is used for health checks. The domain name must meet the following requirements:

  • The name must be 1 to 80 characters in length,
  • and can contain letters, digits, hyphens (-), and periods (.).
  • The domain name must contain at least one period (.), andcannot start or end with a period (.).
  • The rightmost field can contain only letters, and cannot contain digits or hyphens (-).
  • Other fields cannot start or end with a hyphen (-).
Note This parameter exists if the HealthCheckProtocol parameter is set to HTTP.
HealthCheckCodes Array of String 200

The status code for a successful health check. Multiple status codes can be specified as a list.

Note This parameter exists if the HealthCheckProtocol parameter is set to HTTP.

Valid values: http_2xx, http_3xx, http_4xx, and http_5xx. Default value: http_2xx.

HealthCheckHttpVersion String HTTP1.1

HTTP protocol version. Valid values: HTTP1.0 and HTTP1.1 (default).

Note This parameter exists if the HealthCheckProtocol parameter is set to HTTP.
HealthCheckInterval Integer 5

The time interval between two consecutive health checks. Unit: seconds.

Valid values: 1 to 50.

Default value: 2.

HealthCheckMethod String HEAD

Health check method. Valid values:GET and HEAD (default).

Note This parameter exists if the HealthCheckProtocol parameter is set to HTTP.
HealthCheckPath String /test/index.html

The forwarding rule path of health checks.

The value must be 1 to 80 characters in length, and can contain letters, digits, and the following special characters: - / .%?# & =.It can also contain the following extended characters: _ ; ~ ! ( )* [ ] @ $ ^ : ' , +. The URL must start with a forward slash (/).

Note This parameter exists if the HealthCheckProtocol parameter is set to HTTP.
HealthCheckProtocol String HTTP

Health check protocol. Valid values: HTTP and TCP.

HealthCheckTimeout Integer 3

The timeout period of a health check response. If a backend Elastic Compute Service (ECS) instance does not send an expected response within the specified period of time, the ECS instance is considered unhealthy. Unit: seconds.

Valid values: 1 to 300.

Default value: 5.

Note If the value of the HealthCHeckTimeout parameter is smaller than that of the HealthCheckInterval parameter, the value of the HealthCHeckTimeout parameter is ignored and the value of the HealthCheckInterval parameter is regarded as the timeout period.
HealthyThreshold Integer 4

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

Valid values: 2 to 10.

Default value: 3.

UnhealthyThreshold Integer 4

The number of consecutive health checks that a healthy backend server must consecutively fail before it is declared unhealthy. In this case, the health check state is changed from success to fail.

Valid values: 2 to 10.

Default value: 3.

Protocol String HTTP

The server protocol. Valid values:

  • HTTP (default): If you select this option, you can associate the servers with HTTPS, HTTP or QUIC listeners.
  • HTTPS: If you select this option, you can associate the servers with HTTPS listeners.
ResourceGroupId String rg-atstuj3rtop****

The ID of the resource group.

Scheduler String Wrr

The scheduling algorithm. Valid values:

  • Wrr: Backend servers that have higher weights receive more requests than those that have lower weights. This is the default value.
  • Wlc: Requests are distributed based on the weights and number of connections to backend servers. If two backend servers have the same weight, the backend server that has fewer connections receives more requests.
  • Sch: indicates consistent hashing that is based on source IP addresses.
ServerGroupId String sgp-cige6j****

The ID of the server group.

ServerGroupName String Group3

The name of the server group.

ServerGroupStatus String Available

The status of the server group.

  • Provisioning: The server group is being created.
  • Available: The server group is available.
  • Configuring: The configuration of the server group is being modified.
StickySessionConfig Object

The configuration of the sticky session.

Cookie String B490B5EBF6F3CD402E515D22BCDA****

The cookie that is configured on the server.

The value must be 1 to 200 characters in length, and can contain only ASCII characters and digits. It cannot contain commas (,), semicolons (;), or spaces. It cannot start with a dollar sign ($).

Note This parameter exists if the StickySession parameter is set to On and the StickySessionType parameter is set to server.
CookieTimeout Integer 1000

The timeout period of a cookie. Unit: seconds.

Valid values: 1 to 86400.

Default value: 1000.

Note This parameter exists if the StickySessionEnabled parameter is set to true and the StickySessionType parameter is set to Insert.
StickySessionEnabled Boolean true

Indicates whether sticky session is enabled. Valid values: true and false (default).

StickySessionType String Insert

The method that is used to handle a cookie. Valid values:

  • Insert (default): inserts a cookie.

    SLB inserts a cookie (SERVERID) into the first HTTP or HTTPS response that is sent to a client. The next request from the client contains this cookie and the listener forwards this request to the recorded backend server.

  • Server: rewrites a cookie.

    When SLB detects a user-defined cookie, it overwrites the original cookie with the user-defined cookie. The next request from the client will contain the user-defined cookie, and the listener will distribute the request to the recorded backend server.

Note This parameter exists if the StickySession parameter is set to On.
VpcId String vpc-bp15zckdt37pq72zv****

The ID of the VPC that you want to access.

TotalCount Integer 1000

The total data volume of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=ListServerGroups
&ServerGroupIds=["sgp-atstuj3rtop****"]
&ServerGroupNames=["Group3"]
&ResourceGroupId=rg-atstuj3rtop****
&NextToken=FFmyTO70tTpLG6I3FmYAXG****
&MaxResults=50
&VpcId=vpc-bp15zckdt37pq72zv****
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ListServerGroupsResponse>
    <MaxResults>50</MaxResults>
    <NextToken>caeba0bbb2be03f8****</NextToken>
    <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
    <ServerGroups>
        <HealthCheckConfig>
            <HealthCheckConnectPort>80</HealthCheckConnectPort>
            <HealthCheckEnabled>true</HealthCheckEnabled>
            <HealthCheckHost>www.test.com</HealthCheckHost>
            <HealthCheckCodes>200</HealthCheckCodes>
            <HealthCheckHttpVersion>HTTP1.1</HealthCheckHttpVersion>
            <HealthCheckInterval>5</HealthCheckInterval>
            <HealthCheckMethod>HEAD</HealthCheckMethod>
            <HealthCheckPath>/test/index.html</HealthCheckPath>
            <HealthCheckProtocol>HTTP</HealthCheckProtocol>
            <HealthCheckTimeout>3</HealthCheckTimeout>
            <HealthyThreshold>4</HealthyThreshold>
            <UnhealthyThreshold>4</UnhealthyThreshold>
        </HealthCheckConfig>
        <Protocol>HTTP</Protocol>
        <ResourceGroupId>rg-atstuj3rtop****</ResourceGroupId>
        <Scheduler>Wrr</Scheduler>
        <ServerGroupId>sgp-cige6j****</ServerGroupId>
        <ServerGroupName>Group3</ServerGroupName>
        <ServerGroupStatus>Available</ServerGroupStatus>
        <StickySessionConfig>
            <Cookie>B490B5EBF6F3CD402E515D22BCDA****</Cookie>
            <CookieTimeout>1000</CookieTimeout>
            <StickySessionEnabled>true</StickySessionEnabled>
            <StickySessionType>Insert</StickySessionType>
        </StickySessionConfig>
        <VpcId>vpc-bp15zckdt37pq72zv****</VpcId>
    </ServerGroups>
    <TotalCount>1000</TotalCount>
</ListServerGroupsResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "MaxResults" : 50,
  "NextToken" : "caeba0bbb2be03f8****",
  "RequestId" : "CEF72CEB-54B6-4AE8-B225-F876FF7BA984",
  "ServerGroups" : [ {
    "HealthCheckConfig" : {
      "HealthCheckConnectPort" : 80,
      "HealthCheckEnabled" : true,
      "HealthCheckHost" : "www.test.com",
      "HealthCheckCodes" : [ "200" ],
      "HealthCheckHttpVersion" : "HTTP1.1",
      "HealthCheckInterval" : 5,
      "HealthCheckMethod" : "HEAD",
      "HealthCheckPath" : "/test/index.html",
      "HealthCheckProtocol" : "HTTP",
      "HealthCheckTimeout" : 3,
      "HealthyThreshold" : 4,
      "UnhealthyThreshold" : 4
    },
    "Protocol" : "HTTP",
    "ResourceGroupId" : "rg-atstuj3rtop****",
    "Scheduler" : "Wrr",
    "ServerGroupId" : "sgp-cige6j****",
    "ServerGroupName" : "Group3",
    "ServerGroupStatus" : "Available",
    "StickySessionConfig" : {
      "Cookie" : "B490B5EBF6F3CD402E515D22BCDA****",
      "CookieTimeout" : 1000,
      "StickySessionEnabled" : true,
      "StickySessionType" : "Insert"
    },
    "VpcId" : "vpc-bp15zckdt37pq72zv****"
  } ],
  "TotalCount" : 1000
}

Error codes

For a list of error codes, visit the API Error Center.