Creates an availability monitoring task.

This topic describes how to create the task1 availability monitoring in the123456 application group. The TaskType parameter of the task is set to HTTP. After you start the task, the system sends you alerts by using the specified email address and DingTalk chatbot.

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 CreateHostAvailability

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

AlertConfig.NotifyType Integer Yes 0

The alert notification method. Valid values:

0: indicates that alert notifications are sent by using emails and DingTalk chatbots.

AlertConfigEscalationList.N.MetricName String Yes HttpStatus

The metric for which the alert feature is enabled. Valid values of N: 1 to 21. Valid values:

  • HttpStatus: HTTP status code
  • HttpLatency: HTTP response time
  • TelnetStatus: Telnet status code
  • TelnetLatency: Telnet response time
  • PingLostRate: Ping packet loss rate
GroupId Long Yes 123456

The ID of the application group.

TaskName String Yes task1

The name of the availability monitoring task. The name must be 4 to 100 characters in length, and can contain letters, digits, and underscores (_).

TaskType String Yes HTTP

The monitoring type of the availability monitoring task. Valid values:

  • PING
  • TELNET
  • HTTP
TaskScope String No GROUP

The monitoring range of the availability monitoring task. Valid values:

  • GROUP: The system monitors all Elastic Compute Service (ECS) instances in the application group
  • GROUP_SPEC_INSTANCE: The system monitors specified ECS instances in the application group The TaskScope parameter must be used in combination with the InstanceList.N parameter. The InstanceList.N parameter specifies the ECS instances to be monitored.
TaskOption.HttpURI String No https://www.aliyun.com

The URI to be monitored. If the TaskType parameter is set to HTTP, this parameter is required.

TaskOption.TelnetOrPingHost String No www.aliyun.com

The domain name or IP address to be monitored.

Note If the TaskType parameter is set to PING or TELNET, this parameter is required.
TaskOption.HttpResponseCharset String No UTF-8

The character set that is used in the HTTP response.

Note Valid value: UTF-8.
TaskOption.HttpPostContent String No params1=paramsValue1

The post body of the HTTP request.

TaskOption.HttpResponseMatchContent String No ok

The response to the HTTP request.

TaskOption.HttpMethod String No GET

The HTTP request method. Valid values:

  • GET
  • POST
  • HEAD
Note If the TaskType parameter is set to HTTP, this parameter is required.
TaskOption.HttpNegative Boolean No true

The method to trigger an alert. The alert can be triggered based on whether the specified alert rule is included in the response body. Valid values:

  • true: If the HTTP response body includes the alert rule, an alert is triggered.
  • false: If the HTTP response does not include the alert rule, an alert is triggered.
Note If the TaskType parameter is set to HTTP, this parameter takes effect.
TaskOption.HttpHeader String No token:testTokenValue

The header of the HTTP request. Format: Parameter name:Parameter value. Separate multiple parameters with carriage return characters. Example:


params1:value1
params2:value2
TaskOption.Interval Integer No 60

The interval at which detection requests are sent. Unit: seconds. Valid values: 15, 30, 60, 120, 300, 900, 1800, and 3600.

Note This parameter is available only for the CloudMonitor agent V3.5.1 or later.
AlertConfig.StartTime Integer No 0

The start of the time range during which the alert rule is valid. Valid values: 0 to 23.

For example, if the AlertConfig.StartTime parameter is set to 0 and the AlertConfig.EndTime parameter is set to 22, the related alert rule is valid from 00:00:00 to 22:00:00.

Note If the threshold of a metric that is specified in an invalid alert rule is exceeded, no alert notification is sent.
AlertConfig.EndTime Integer No 22

The end of the time range during which the alert rule is valid. Valid values: 0 to 23.

For example, if the AlertConfig.StartTime parameter is set to 0 and the AlertConfig.EndTime parameter is set to 22, this setting indicates that the related alert rule is valid from 00:00:00 to 22:00:00.

Note If the threshold of a metric that is specified in an invalid alert rule is exceeded, no alert notification is sent.
AlertConfig.SilenceTime Integer No 86400

The mute period during which alert notifications are not sent even if the alert rule is triggered. Unit: seconds. Default value: 86400. The default value indicates one day.

AlertConfig.WebHook String No https://www.aliyun.com/webhook.json

The callback URL.

AlertConfigEscalationList.N.Aggregate String No Value

The method used to calculate metric values that trigger alerts. Valid values of N: 1 to 21. The following points describe the correspondence between metrics and calculation methods:

  • HttpStatus: Value
  • HttpLatency: Average
  • TelnetStatus: Value
  • TelnetLatency: Average
  • PingLostRate: Average
Note The value Value indicates the original value and is used for metrics such as status codes. The value Average indicates the average value and is used for metrics, such as the latency and packet loss rate.
AlertConfigEscalationList.N.Times Integer No 3

The consecutive number of times for which the metric value is measured before an alert is triggered. Valid values of N: 1 to 21.

AlertConfigEscalationList.N.Operator String No >

The comparison operator that is used in the alert rule. Valid values of N: 1 to 21. Valid values:

  • >
  • >=
  • <
  • <=
  • =
AlertConfigEscalationList.N.Value String No 90

The threshold of the metric value. Valid values of N: 1 to 21.

InstanceList.N RepeatList No i-absdfkwl321****

The ECS instances to be monitored. Valid values of N: 1 to 21.

Note If the TaskScope parameter is set to GROUP_SPEC_INSTANCE, this parameter is required.

For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
RequestId String ACBDBB40-DFB6-4F4C-8957-51FFB233969C

The ID of the request.

Code String 200

The HTTP status code.

Note The HTTP status code 200 indicates that the request succeeds.
Success Boolean true

Indicates whether the call succeeds. Valid values:

  • true: The call succeeds.
  • false: The call fails.
TaskId Long 12345

The ID of the availability monitoring task.

Message String The specified resource is not found.

The error message.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateHostAvailability
&AlertConfig.NotifyType=0
&AlertConfigEscalationList.1.MetricName=HttpStatus
&GroupId=123456
&TaskName=task1
&TaskType=HTTP
&<Common request parameters>

Sample success responses

XML format

<CreateHostAvailabilityResponse>
	  <TaskId>12345</TaskId>
	  <RequestId>CDA78493-F10F-485F-98AD-B4C0B40AB225</RequestId>
	  <Code>200</Code>
	  <Success>true</Success>
</CreateHostAvailabilityResponse>

JSON format

{
	"TaskId": "12345",
	"RequestId": "CDA78493-F10F-485F-98AD-B4C0B40AB225",
	"Code": 200,
	"Success": true
}

Error codes

HttpCode Error code Error message Description
404 ResourceNotFound The specified resource is not found. The error message returned because the specified resource is not found.

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