Creates a health check template.

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 CreateHealthCheckTemplate

The operation that you want to perform.

Set the value to CreateHealthCheckTemplate.

ClientToken String No 5A2CFF0E-5718-45B5-9D4D-70B3FF3898

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.

HealthCheckTemplateName String No HealthCheckTemplate1

The name of the health check template.

The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.

HealthCheckConnectPort Integer No 80

The port that is used for health checks.

Valid values: 0 to 65535.

Default value: 0. This value indicates that the server port is used for health checks.

HealthCheckHost String No $_ip

The domain name that is used for health checks.

Default value: $SERVER_IP. The domain name must be 1 to 80 characters in length. When you specify a domain name, follow these rules:

  • The domain name can contain lowercase 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 (-).

This parameter is required only if the HealthCheckProtocol parameter is set to HTTP.

HealthCheckCodes Array of String No http_2xx,http_3xx

The HTTP status code of a successful health check.

Default value: http_2xx. The HTTP status code that indicates a successful health check. Multiple status codes are separated with commas.

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

Note This parameter is required only if the HealthCheckProtocol parameter is set to HTTP.
HealthCheckInterval Integer No 2

The interval between two consecutive health checks.

Valid values: 1 to 50. Unit: seconds.

Default value: 2.

HealthCheckTimeout Integer No 5

The timeout period of a health check response. If the backend server does not respond within the specified timeout period, the backend server is declared unhealthy.

Valid values: 1 to 300. Unit: seconds.

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.
HealthCheckPath String No /test/index.html

The URL that is used for health checks.

The URL must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.), percent signs (%), question marks (?), number signs (#), and ampersands (&). The URL can also contain the following extended characters: _ ; ~ ! ( )* [ ] @ $ ^ : ' , +. The URL must start with a forward slash (/).

Note This parameter is required only if the HealthCheckProtocol parameter is set to HTTP.
HealthCheckMethod String No HEAD

The health check method.

Valid values: GET and HEAD.

Default value: HEAD.

Note This parameter is required only if the HealthCheckProtocol parameter is set to HTTP.
HealthCheckProtocol String No HTTP

The protocol that is used for health checks.

Valid values: HTTP and TCP.

Default value: HTTP.

HealthCheckHttpVersion String No HTTP 1.0

The version of the HTTP protocol.

Valid values: HTTP 1.0 and HTTP 1.1.

Default value: HTTP 1.1.

Note This parameter is required only if the HealthCheckProtocol parameter is set to HTTP.
HealthyThreshold Integer No 4

The number of times that an unhealthy backend server must consecutively pass health checks before it is declared healthy (from fail to success).

Valid values: 2 to 10.

Default value: 3.

UnhealthyThreshold Integer No 4

The number of times that an healthy backend server must consecutively fail health checks before it is declared unhealthy (from success to fail).

Valid values: 2 to 10.

Default value: 3.

DryRun Boolean No true

Specifies whether to precheck the API request. Valid values:

true: only prechecks the API request. If you select this option, the specified endpoint service is not created after the request passes the precheck. The system prechecks the required parameters, request format, and service limits. If the request fails the precheck, the corresponding error message is returned. If the request passes the precheck, the DryRunOperation error code is returned.

false (default): checks the request. After the request passes the check, an http_2xx status code is returned and the operation is performed.

Response parameters

Parameter Type Example Description
HealthCheckTemplateId String hct-1224334

The ID of the health check template.

RequestId String 365F4154-92F6-4AE4-92F8-7FF34B540710

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?HealthCheckInterval=5
&UnhealthyThreshold=4
&HealthCheckTemplateName=Group1
&HealthCheckHost=$_ip
&HealthCheckPath=/test/index.html
&DryRun=true
&HealthCheckHttpVersion=HTTP1.0
&HealthCheckTimeout=3
&HealthCheckConnectPort=80
&HealthCheckHttpCodes=[ http_2xx ]
&HealthCheckMethod=HEAD
&HealthyThreshold=4
&HealthCheckProtocol=HTTP
&ClientToken=5A2CFF0E-5718-45B5-9D4D-70B3FF3898
&<Common request parameters>

Sample success responses

XML format

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

<CreateHealthCheckTemplateResponse>
<HealthCheckTemplateId>hct-1224334</HealthCheckTemplateId>
<RequestId>365F4154-92F6-4AE4-92F8-7FF34B540710</RequestId>
</CreateHealthCheckTemplateResponse>

JSON format

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

{
  "HealthCheckTemplateId" : "hct-1224334",
  "RequestId" : "365F4154-92F6-4AE4-92F8-7FF34B540710"
}

Error codes

HttpCode Error code Error message Description
400 QuotaExceeded.HealthCheckTemplatesNum The quota of %s is exceeded, usage %s/%s. The error message returned because the usage %s has exceeded the quota %s.

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