CreateHostAvailability
Creates an availability monitoring task.
Operation description
This topic provides an example of creating an availability monitoring task named task1 with the probe type set to HTTP in the application group 123456. Alert notifications are sent to you by email and DingTalk chatbot.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:CreateHostAvailability |
create |
*HostAvailability
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| GroupId |
integer |
Yes |
The ID of the application group. |
123456 |
| TaskName |
string |
Yes |
The name of the availability monitoring task. The name must be 4 to 100 characters in length and can contain letters, digits, underscores (_), and Chinese characters. |
task1 |
| TaskScope |
string |
No |
The probe scope of the availability monitoring task. Valid values:
|
GROUP |
| TaskType |
string |
Yes |
The probe type of the availability monitoring task. Valid values:
|
HTTP |
| TaskOption.HttpURI |
string |
No |
The URI for HTTP or Telnet probes. |
https://www.aliyun.com telnet://127.0.0.1:80 |
| TaskOption.TelnetOrPingHost |
string |
No |
The domain name or IP address to be probed. Note
If the probe type is PING, you must set this parameter. |
www.aliyun.com |
| TaskOption.HttpResponseCharset |
string |
No |
The response character set for HTTP probes. Note
Only UTF-8 is supported. |
UTF-8 |
| TaskOption.HttpPostContent |
string |
No |
The POST content of the HTTP probe request. |
params1=paramsValue1 |
| TaskOption.HttpResponseMatchContent |
string |
No |
The content to be matched in the response. |
ok |
| TaskOption.HttpMethod |
string |
No |
The HTTP method for the probe. Valid values:
Note
If the probe type is HTTP, you must set this parameter. |
GET |
| TaskOption.HttpNegative |
boolean |
No |
The alert rule for matching the HTTP response content. Valid values:
Note
This parameter takes effect only when the probe type is HTTP. |
true |
| TaskOption.HttpHeader |
string |
No |
The headers of the HTTP request. The format is |
token:testTokenValue |
| TaskOption.Interval |
integer |
No |
The probe interval. Unit: seconds. Valid values: 15, 30, 60, 120, 300, 900, 1800, and 3600. Note
This parameter is supported only by CloudMonitor agent V3.5.1 or later. |
60 |
| AlertConfig.NotifyType |
integer |
Yes |
The alert notification type. Valid values:
|
0 |
| AlertConfig.StartTime |
integer |
No |
The start time of the effective period for alerts. The value must be an integer ranging from 0 to 23. Unit: hours. The value specifies the hour when the effective period starts. The actual start time is 00:00:00 of the specified hour. For example, if you set this parameter to 0, the effective period starts at 00:00:00. The time zone is UTC+8 (Beijing time). Note
Note: If the current time is not within the effective time window, the system does not send alert notifications even if the threshold is exceeded. |
0 |
| AlertConfig.EndTime |
integer |
No |
The end time of the effective period for alerts. The value must be an integer ranging from 0 to 23. Unit: hours. The value specifies the hour when the effective period ends. The actual end time is 00:00:00 of the specified hour. For example, if you set this parameter to 22, the effective period ends at 22:00:00. The time zone is UTC+8 (Beijing time). Note
Note: If the current time is not within the effective time window, the system does not send alert notifications even if the threshold is exceeded. |
22 |
| AlertConfig.SilenceTime |
integer |
No |
The mute period. Unit: seconds. Default value: 86400 (1 day). |
86400 |
| AlertConfig.WebHook |
string |
No |
The webhook address. |
https://www.aliyun.com/webhook.json |
| AlertConfigEscalationList |
array<object> |
Yes |
None. |
|
|
object |
No |
None. |
||
| MetricName |
string |
Yes |
The metric for the alert. Valid values of N: 1 to 21. Valid values:
|
HttpStatus |
| Value |
string |
No |
The alert threshold. Valid values of N: 1 to 21. |
90 |
| Times |
integer |
No |
The number of alert retries. Valid values of N: 1 to 21. |
3 |
| Operator |
string |
No |
The comparison operator for the alert rule. Valid values of N: 1 to 21. Valid values:
|
> |
| Aggregate |
string |
No |
The aggregation method for the alert. Valid values of N: 1 to 21. Valid values vary based on the metric:
Note
The aggregation method for status codes is the original value (Value). The aggregation method for response time or packet loss rate is the average value (Average). |
Value |
| InstanceList |
array |
No |
The list of ECS instances that initiate the probes. Valid values of N: 1 to 21. Note
You must set this parameter when TaskScope is set to GROUP_SPEC_INSTANCE. |
i-absdfkwl321**** |
|
string |
No |
The list of ECS instances that initiate the probes. Valid values of N: 1 to 21. Note
You must set this parameter when TaskScope is set to GROUP_SPEC_INSTANCE. |
2 |
|
| AlertConfigTargetList |
array<object> |
No |
The alert trigger targets. |
|
|
object |
No |
The alert trigger targets. |
||
| Id |
string |
No |
The ID of the alert trigger target. |
1 |
| Arn |
string |
No |
The ARN of the resource. Format:
|
acs:mns:cn-hangzhou:120886317861****:/queues/test/message |
| Level |
string |
No |
The alert level. Valid values:
|
["INFO", "WARN", "CRITICAL"] |
| JsonParams |
string |
No |
The JSON-formatted parameters for the alert callback. |
{"customField1":"value1","customField2":"$.name"} |
For more information about common request parameters, see Common parameters.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Code |
string |
The HTTP status code. Note
A status code of 200 indicates that the request is successful. |
200 |
| Message |
string |
The error message. |
The specified resource is not found. |
| RequestId |
string |
The request ID. |
ACBDBB40-DFB6-4F4C-8957-51FFB233969C |
| TaskId |
integer |
The ID of the availability monitoring task. |
12345 |
| Success |
boolean |
Indicates whether the operation is successful. Valid values:
|
true |
Examples
Success response
JSON format
{
"Code": "200",
"Message": "The specified resource is not found.",
"RequestId": "ACBDBB40-DFB6-4F4C-8957-51FFB233969C",
"TaskId": 12345,
"Success": true
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | ParameterInvalid | Parameter invalid. | The parameter is missing or invalid. |
| 412 | ResouceOverLimit | The task over limit | |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 403 | AccessForbidden | User not authorized to operate on the specified resource. | |
| 404 | ResourceNotFound | %s | |
| 409 | ResourceConflict | Concurrent modification of resources. | |
| 409 | ResourceExist | Resources already exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.