Creates an availability monitoring task.
Operation description
This topic provides an example on how to create an availability monitoring task named task1
in an application group named 123456
. The TaskType parameter of the task is set to HTTP
. After you start the task, the system sends alerts by using the specified email address and DingTalk chatbot.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
cms:CreateHostAvailability | create |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
GroupId | long | 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, and underscores (_). | task1 |
TaskScope | string | No | The range of instances that are monitored by the availability monitoring task. Valid values:
| GROUP |
TaskType | string | Yes | The monitoring type of the availability monitoring task. Valid values:
| HTTP |
TaskOption.HttpURI | string | No | The URI that you want to monitor. This parameter is required if the TaskType parameter is set to HTTP or Telnet. | https://www.aliyun.com |
TaskOption.TelnetOrPingHost | string | No | The domain name or IP address that you want to monitor. Note
This parameter is required if the TaskType parameter is set to PING.
| www.aliyun.com |
TaskOption.HttpResponseCharset | string | No | The character set that is used in the HTTP response. Note
Only UTF-8 is supported.
| UTF-8 |
TaskOption.HttpPostContent | string | No | The content of the HTTP POST request. | params1=paramsValue1 |
TaskOption.HttpResponseMatchContent | string | No | The response to the HTTP request. | ok |
TaskOption.HttpMethod | string | No | The HTTP request method. Valid values:
Note
This parameter must be specified when TaskType is set to HTTP.
| GET |
TaskOption.HttpNegative | boolean | No | 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:
Note
This parameter must be specified when TaskType is set to HTTP.
| true |
TaskOption.HttpHeader | string | No | The header of the HTTP request. Format:
| token:testTokenValue |
TaskOption.Interval | integer | No | 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.
| 60 |
AlertConfig.NotifyType | integer | Yes | The alert notification methods. Valid values: 0: Alert notifications are sent by using emails and DingTalk chatbots. | 0 |
AlertConfig.StartTime | integer | No | The beginning of the time range during which the alert rule is effective. Valid values: 0 to 23. For example, if the Note
Alert notifications are sent based on the specified threshold only if the alert rule is effective.
| 0 |
AlertConfig.EndTime | integer | No | The end of the time range during which the alert rule is effective. Valid values: 0 to 23. For example, if the Note
Alert notifications are sent based on the specified threshold only if the alert rule is effective.
| 22 |
AlertConfig.SilenceTime | integer | No | The mute period during which new alerts are not sent even if the trigger conditions are met. Unit: seconds. Default value: 86400. The default value indicates one day. | 86400 |
AlertConfig.WebHook | string | No | The callback URL. | https://www.aliyun.com/webhook.json |
AlertConfigEscalationList | array<object> | Yes | None | |
object | Yes | None | ||
MetricName | string | Yes | The metric for which the alert feature is enabled. 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 consecutive number of times for which the metric value meets the alert condition before an alert is triggered. Valid values of N: 1 to 21. | 3 |
Operator | string | No | The comparison operator that is used in the alert rule. Valid values of N: 1 to 21. Valid values:
| > |
Aggregate | string | No | The method used to calculate the metric values that trigger alerts. Valid values of N: 1 to 21. Valid values:
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.
| Value |
InstanceList | array | No | The ECS instances that are monitored. Valid values of N: 1 to 21. Note
This parameter must be specified when TaskScope is set to GROUP_SPEC_INSTANCE .
| |
string | No | The ECS instances that are monitored. Valid values of N: 1 to 21. Note
This parameter must be specified when TaskScope is set to GROUP_SPEC_INSTANCE .
| 2 | |
AlertConfigTargetList | array<object> | No | The resources for which alerts are triggered. | |
object | No | The resource for which alerts are triggered. | ||
Id | string | No | The ID of the resource for which alerts are triggered. | 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 parameters of the alert callback. The parameters are in the JSON format. | {"customField1":"value1","customField2":"$.name"} |
For more information about common request parameters, see Common parameters.
Response parameters
Examples
Sample success responses
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 |
---|---|---|
400 | ParameterInvalid | Illegal parameters. |
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. |
412 | ResouceOverLimit | The task over limit |
500 | InternalError | The request processing has failed due to some unknown error. |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2022-08-05 | The Error code has changed. The request parameters of the API has changed | View Change Details |
2022-03-22 | The Error code has changed | View Change Details |