Creates an availability monitoring task by calling the CreateHostAvailability operation.
Operation description
This topic provides an example of how to create an availability monitoring task named task1 with the detection type set to HTTP in application group 123456. Alert notifications are sent 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 detection scope of the availability monitoring task. Valid values:
|
GROUP |
| TaskType |
string |
Yes |
The detection type of the availability monitoring task. Valid values:
|
HTTP |
| TaskOption.HttpURI |
string |
No |
HTTP、Telnet 探测类型的探测 URI 地址。 |
https://www.aliyun.com telnet://127.0.0.1:80 |
| TaskOption.TelnetOrPingHost |
string |
No |
探测的域名或地址。 Note
如果探测任务类型为 PING,则需要设置该参数。 |
www.aliyun.com |
| TaskOption.HttpResponseCharset |
string |
No |
HTTP 探测类型的响应字符集。 Note
仅支持 UTF-8。 |
UTF-8 |
| TaskOption.HttpPostContent |
string |
No |
HTTP 探测类型探测请求的 Post 内容。 |
params1=paramsValue1 |
| TaskOption.HttpResponseMatchContent |
string |
No |
匹配响应的内容。 |
ok |
| TaskOption.HttpMethod |
string |
No |
探测类型的方法。取值:
Note
如果任务的探测类型为 HTTP,则需要设置该参数。 |
GET |
| TaskOption.HttpNegative |
boolean |
No |
匹配 HTTP 响应内容的报警规则。取值:
Note
如果任务的探测类型为 HTTP,则该参数生效。 |
true |
| TaskOption.HttpHeader |
string |
No |
HTTP 请求的 Header。格式为 |
token:testTokenValue |
| TaskOption.Interval |
integer |
No |
探测频率。单位:秒。取值:15、30、60、120、300、900、1800 和 3600。 Note
仅 3.5.1 及以上版本的云监控插件支持该参数。 |
60 |
| AlertConfig.NotifyType |
integer |
Yes |
报警通知类型。取值: 0:邮件+钉钉机器人。 |
0 |
| AlertConfig.StartTime |
integer |
No |
报警生效的开始时间。取值范围:0~23。 例如: Note
如果报警不在生效时间内,则超过阈值也不会发送报警通知。 |
0 |
| AlertConfig.EndTime |
integer |
No |
报警生效的结束时间。取值范围:0~23。 例如: Note
如果报警不在生效时间内,则超过阈值也不会发送报警通知。 |
22 |
| AlertConfig.SilenceTime |
integer |
No |
通道沉默时间。单位:秒,默认值:86400(1 天)。 |
86400 |
| AlertConfig.WebHook |
string |
No |
URL 回调地址。 |
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 statistical method for the alert. Valid values of N: 1 to 21. The valid values vary based on the metric:
Note
The statistical method for status code metrics is the raw value (Value). The statistical method for latency or packet loss rate metrics is the average value (Average). |
Value |
| InstanceList |
array |
No |
The list of ECS instances that initiate detection. Valid values of N: 1 to 21. Note
Set this parameter when |
i-absdfkwl321**** |
|
string |
No |
The list of ECS instances that initiate detection. Valid values of N: 1 to 21. Note
Set this parameter when |
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 Alibaba Cloud Resource Name (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 status code. Note
A value of 200 indicates success. |
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 was 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. | |
| 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.