Creates a site monitoring task.
Operation description
This topic provides an example on how to create a site monitoring task named HanZhou_ECS1
. The URL that is monitored by the task is https://www.aliyun.com
and the type of the task is HTTPS
.
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:CreateSiteMonitor | create |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
Address | string | Yes | The URL or IP address that is monitored by the task. | https://www.aliyun.com |
TaskType | string | Yes | The protocol that is used by the site monitoring task. Valid values: HTTP, HTTPS, PING, TCP, UDP, DNS, SMTP, POP3, FTP, and WEBSOCKET. | HTTPS |
TaskName | string | Yes | The name of the site monitoring task. The name must be 4 to 100 characters in length, and can contain letters, digits, and underscores (_). | HanZhou_ECS1 |
Interval | string | No | The interval at which detection requests are sent. Valid values: 1, 5, 15, 30, and 60. Unit: minutes. Default value: 1. | 1 |
IspCities | string | No | The information of the detection points. If you leave this parameter empty, the system randomly selects three detection points. The value is a JSON array. Example: For information about how to obtain detection points, see DescribeSiteMonitorISPCityList . | [{"city":"546","isp":"465"},{"city":"572","isp":"465"},{"city":"738","isp":"465"}] |
OptionsJson | string | No | The extended options of the protocol that is used by the site monitoring task. The options vary based on the protocol. | {"time_out":5000} |
AlertIds | string | No | The ID of the alert rule. For more information about how to obtain the ID of an alert rule, see DescribeMetricRuleList . | SystemDefault_acs_ecs_dashboard_InternetOutRate_Percent |
CustomSchedule | string | No | The custom detection period. You can only select a time period from Monday to Sunday for detection. | {"start_hour":0,"end_hour":24, "days":[0], "time_zone":"Local"} |
The following tables describe the extended options of the HTTP, HTTPS, PING, TCP, UDP, DNS, WEBSOCKET, SMTP, POP3, and FTP protocols specified by the TaskType parameter.
- HTTP or HTTPS
Parameter | Type | Description |
---|---|---|
http_method | String | The HTTP or HTTPS request method. Valid values: GET, POST, and HEAD. Default value: GET. |
header | String | The custom HTTP headers that are separated by line feeds (\n).Each header must comply with the HTTP protocol. Each header must be a key-value pair in which the key and value are separated by a colon (:). |
cookie | String | The HTTP cookie that is specified in compliance with the HTTP request standard. |
request_content | String | The content of the request. The content can be in the JSON or form format. If this parameter is not specified, the request body is empty. |
response_content | String | The expected content of the response. The first 64 bytes of the content returned by the HTTP server are checked during site monitoring. |
match_rule | String | 0: The detection is successful if the response does not contain the content specified by the response_content parameter.1: The detection is successful if the response contains the content specified by the response_content parameter. |
username | String | If the username parameter is specified, the HTTP request contains the basic authentication header. |
password | String | The password that is used to authenticate the HTTP or HTTPS request. |
time_out | int | The timeout period. Unit: milliseconds. Default value: 5. |
max_redirect | int | The maximum number of redirections. The default value is 5 for a detection point that is running on an Elastic Compute Service (ECS) instance and 2 for a detection point that is provided by a carrier.To disable redirections, set the value to 0.Valid values: 0 to 50. |
- PING
Parameter | Type | Description |
---|---|---|
failure_rate | Text | If the rate of the failed pings exceeds the value of this parameter, the detection fails and the status code 610 or 615 is returned. The error message of the status code 610 is PingAllFail and the error message of the status code 615 is PingPartialFail.Default value: 0.1. |
ping_num | int | The number of times that the monitored address is pinged. Default value: 10.Valid values: 1 to 100. |
- DNS
Parameter | Type | Description |
---|---|---|
dns_server | string | The domain name or IP address of the Domain Name System (DNS) server. |
dns_type | string | The type of the DNS records to query. Valid values: A, NS, CNAME, MX, TXT, ANY, and AAAA. |
expect_value | string | The list of expected values. Separate the expected values with space characters. |
match_rule | string | The relationship between the list of expected values and the list of DNS results. If the two lists do not meet the specified relationship, the detection fails. Valid values:Empty string or IN_DNS: The list of expected values is a subset of the list of DNS results.DNS_IN: The list of DNS results is a subset of the list of expected values.EQUAL: The list of DNS results is the same as the list of expected values.ANY: The list of DNS results intersects with the list of expected values. |
- FTP
Parameter | Type | Description |
---|---|---|
port | int | The port number of the FTP server. If this parameter is not specified, the default value is used. The default port number is 21 for FTP and 990 for FTPS. |
username | string | The username that is used to log on to the FTP server. If this parameter is not specified, anonymous logon is used. |
password | string | The password that is used to log on to the FTP server. |
- POP3 or SMTP
Parameter | Type | Description |
---|---|---|
port | int | The port number of the POP3 or SMTP server. The default port number is 110 for POP3, 995 for POP3S, and 25 for SMTP. |
username | string | The username that is used to log on to the POP3 or SMTP server. The username and password that are used to log on to the POP3 or SMTP server are required. |
password | string | The password that is used to log on to the POP3 or SMTP server. The username and password that are used to log on to the POP3 or SMTP server are required. |
- TCP or UDP
Parameter | Type | Description |
---|---|---|
port | int | The port number of the TCP or UDP server. |
request_content | string | The content of the request. If the request_format parameter is set to hex, the value of the request_content parameter is parsed in the hexadecimal format. |
request_format | string | If the request_format parameter is set to another value, the value of the request_content parameter is sent to the TCP or UDP server as a regular string. |
response_content | string | The content of the response. If the response from the TCP or UDP server does not contain the content specified by the response_content parameter, the detection fails.If the response_format parameter is set to hex, the value of the response_content parameter is parsed in the hexadecimal format.If the response_format parameter is set to another value, the value of the response_content parameter is parsed as a regular string. |
- WEBSOCKET
Parameter | Type | Description |
---|---|---|
request_content | string | The message content. |
empty_message | boolean | Allows the server to return no message or an empty string. |
Response parameters
Examples
Sample success responses
JSON
format
{
"Code": "200",
"CreateResultList": {
"CreateResultList": [
{
"TaskId": "2c8dbdf9-a3ab-46a1-85a4-f094965e****",
"TaskName": "HanZhou_ECS1"
}
]
},
"Data": {
"AttachAlertResult": {
"Contact": [
{
"Code": "200",
"Message": "successful",
"RequestId": "5dd33455-4f65-4b0c-9200-33d66f3f340b",
"RuleId": "SystemDefault_acs_ecs_dashboard_InternetOutRate_Percent",
"Success": "true"
}
]
}
},
"Message": "Successful",
"RequestId": "68192f5d-0d45-4b98-9724-892813f86c71",
"Success": "true"
}
Error codes
HTTP status code | Error code | Error message |
---|---|---|
400 | InvalidQueryParameter | %s |
400 | IllegalAddress | Illegal HTTP address |
400 | OperationError | Operation failed |
400 | TaskNotExists | Task does not exist |
400 | OperatorInvalid | Operator invalid |
400 | OperatorCityInvalid | Operator City invalid |
400 | OperatorCityInvalid | %s |
400 | NameRepeat | Task name repeat |
400 | CreateAlarmError | Create alarm error |
400 | NameNotExists | Task name not exists |
400 | IllegalAddress | Probe address not allowed |
401 | AccessDeniedException | You donot have sufficient access to perform this action. |
402 | LimitExceeded | The quota for this customer had been reached. |
403 | Forbidden | %s |
403 | RestrictedUser | The user's operation is restricted, please register NAAM product code |
406 | ExceedingQuota | Exceeding quota limits. |
409 | %s | %s |
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 |
---|---|---|
2023-08-04 | The Error code has changed. The request parameters of the API has changed | View Change Details |
2023-06-19 | The Error code has changed | View Change Details |
2022-06-22 | API Description Update. The Error code has changed | View Change Details |