CreateSiteMonitor
Creates a site monitoring task.
Operation description
This topic provides an example of creating a site monitoring task named HanZhou_ECS1. The monitored address of the task is https://www.aliyun.com, and the monitoring type is HTTP.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:CreateSiteMonitor |
create |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Address |
string |
Yes |
The URL or IP address of the monitoring task. |
https://www.aliyun.com |
| TaskType |
string |
Yes |
The monitoring type of the monitoring task. Site monitoring tasks support the following types: HTTP, PING, TCP, UDP, DNS, SMTP, POP3, FTP, and WEBSOCKET. The HTTP type applies to both HTTP and HTTPS addresses. There is no separate HTTPS type. |
HTTP |
| TaskName |
string |
Yes |
The name of the monitoring task. The name must be 4 to 100 characters in length and can contain letters, digits, underscores (_), and Chinese characters. |
HanZhou_ECS1 |
| Interval |
string |
No |
The monitoring frequency. Valid values: 1 minute, 5 minutes, 15 minutes, 30 minutes, and 60 minutes. Default value: 1 minute. |
1 |
| IspCities |
string |
No |
The probe information. If this parameter is left empty, the system randomly selects three detection points. The value is a JSON array. Example: |
[{"city":"546","isp":"465"},{"city":"572","isp":"465"},{"city":"738","isp":"465"}] |
| OptionsJson |
string |
No |
The advanced extension options for the protocol type of the monitoring task. Different protocol types correspond to different extension options. |
{"time_out":5000} |
| AlertIds |
string |
No |
The ID of the alert rule. For more information about how to obtain the ID of an existing alert rule in CloudMonitor, see DescribeMetricRuleList. |
SystemDefault_acs_ecs_dashboard_InternetOutRate_Percent |
| AgentGroup |
string |
No |
The detection point group used by the monitoring task. Different options correspond to different detection point types. PC corresponds to PC clients, MOBIEL corresponds to mobile clients, and FC corresponds to VPC internal network detection. If this parameter is not specified, the default value is PC. |
PC |
| CustomSchedule |
string |
No |
The custom detection cycle. You can only select a specific time period from Monday to Sunday for detection. |
{"start_hour":0,"end_hour":24, "days":[0], "time_zone":"Local"} |
| VpcConfig |
string |
No |
The network information required when creating a VPC internal network monitoring task. You must provide a JSON string that contains the following four fields: vpcId, vswitchId, securityGroupId, and region. |
{"vpcId": "vpc-xxxxxx", "vswitchId": "vsw-xxxxxx", "securityGroupId": "sg-xxxxxx", "region": "cn-beijing"} |
The following tables describe how to configure the advanced parameters for HTTP (including HTTPS), PING, TCP, UDP, DNS, WEBSOCKET, SMTP, POP3, and FTP in TaskType.
HTTP (including HTTPS)
| Parameter | Type | Description |
| http_method | String | The HTTP or HTTPS request method. Valid values: GET, POST, and HEAD. Default value: GET. |
| header | String | Custom HTTP headers separated by line breaks (\n). The format of each header line must comply with the HTTP protocol (key-value pairs separated by half-width colons). |
| cookie | String | The cookie. The format is the same as that of a standard HTTP request. |
| request_content | String | The request content. Valid formats: JSON and form. If this parameter is not provided, the request does not contain a body. |
| response_content | String | The expected response content. During detection, the system checks the first 64 bytes returned by the HTTP server. |
| match_rule | int | 0: The detection is successful if the response does not contain the response_content. 1: The detection is successful if the response contains the response_content. |
| username | String | The username. If a username is provided, the HTTP request carries the BasicAuth header. |
| password | String | The password for HTTP or HTTPS request authentication. |
| time_out | int | The timeout period. Unit: milliseconds. Default value: 5. |
| max_redirect | int | The maximum number of redirects. The default value is 5 for ECS probes and 2 for carrier probes. To disable redirects, set this parameter to 0. Valid values: 0 to 50. |
PING
| Parameter | Type | Description |
| failure_rate | String | If the PING failure rate exceeds this value, the detection fails and returns 610 (PingAllFail) or 615 (PingPartialFail). Default value: 0.1. |
| ping_num | int | The number of PING requests. Default value: 10. Valid values: 1 to 100. |
DNS.
| Parameter | Type | Description |
| dns_server | string | The address of the DNS server. It can be a domain name or an IP address. |
| dns_type | string | The DNS query type. Valid values: A, NS, CNAME, MX, TXT, ANY, and AAAA. |
| expect_value | string | The list of expected values separated by spaces. |
| match_rule | string | The relationship between the expected value list and the DNS record list. If the specified relationship is not met, the detection fails. Empty string or IN_DNS: The expected value list is a subset of the DNS record list. DNS_IN: The DNS record list is a subset of the expected value list. EQUAL: The DNS record list is equal to the expected value list. ANY: The DNS record list and the expected value list have an intersection (the intersection is not empty). |
FTP.
| Parameter | Type | Description |
| port | int | The port number of the FTP server. If this parameter is not provided, the default value is used. The default port is 21 for FTP and 990 for FTPS. |
| username | string | The FTP username. If this parameter is not provided, anonymous logon is used. |
| password | string | The FTP password. |
POP3 or SMTP.
| Parameter | Type | Description |
| port | int | The port number of the POP3 or SMTP server. The default port is 110 for POP3, 995 for POP3S, and 25 for SMTP. |
| username | string | The username for POP3 or SMTP. Both the username and password are required for POP3 or SMTP. |
| password | string | The password for POP3 or SMTP. Both the username and password are required for POP3 or SMTP. |
TCP or UDP.
| Parameter | Type | Description |
| port | int | The port of the TCP or UDP server. |
| request_content | string | The request content. If request_format is set to hex, the request_content is in hexadecimal compact format. |
| request_format | string | The request format. If request_format is set to a value other than hex, the request_content is sent to the TCP or UDP server as a plain string. |
| response_content | string | The response content. If the content returned by the TCP or UDP server does not contain the response_content, the detection fails. If response_format is set to hex, the response_content is in hexadecimal compact format. If it is set to a value other than hex, the response_content is a plain string. |
WEBSOCKET.
| Parameter | Type | Description |
| request_content | string | The message content. |
| empty_message | boolean | Specifies whether to allow the server to return no message or an empty string. |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Code |
string |
The status code. Note
200 indicates success. |
200 |
| Message |
string |
The returned message. |
Successful |
| RequestId |
string |
The request ID. |
68192f5d-0d45-4b98-9724-892813f86c71 |
| Success |
string |
Indicates whether the operation was successful. Valid values:
|
true |
| Data |
object |
The result details of the monitoring task. |
|
| AttachAlertResult |
object |
||
| Contact |
array<object> |
The list of results for associating alert rules with the site monitoring task. |
|
|
object |
|||
| Code |
string |
The HTTP status code of the request to associate the alert rule. |
200 |
| Message |
string |
The returned message of the request to associate the alert rule. |
successful |
| RequestId |
string |
The request ID of the request to associate the alert rule. |
5dd33455-4f65-4b0c-9200-33d66f3f340b |
| Success |
string |
Indicates whether the alert rule was successfully associated. A value of true indicates success, and a value of false indicates failure. |
true |
| RuleId |
string |
The ID of the associated alert rule. |
SystemDefault_acs_ecs_dashboard_InternetOutRate_Percent |
| CreateResultList |
object |
||
| CreateResultList |
array<object> |
The list of created site monitoring tasks. |
|
|
object |
|||
| TaskId |
string |
The ID of the created site monitoring task. |
2c8dbdf9-a3ab-46a1-85a4-f094965e**** |
| TaskName |
string |
The name of the created site monitoring task. |
HanZhou_ECS1 |
Examples
Success response
JSON format
{
"Code": "200",
"Message": "Successful",
"RequestId": "68192f5d-0d45-4b98-9724-892813f86c71",
"Success": "true",
"Data": {
"AttachAlertResult": {
"Contact": [
{
"Code": "200",
"Message": "successful",
"RequestId": "5dd33455-4f65-4b0c-9200-33d66f3f340b",
"Success": "true",
"RuleId": "SystemDefault_acs_ecs_dashboard_InternetOutRate_Percent"
}
]
}
},
"CreateResultList": {
"CreateResultList": [
{
"TaskId": "2c8dbdf9-a3ab-46a1-85a4-f094965e****",
"TaskName": "HanZhou_ECS1"
}
]
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | DryRunOperation | Request validation has been passed with DryRun flag set. | |
| 400 | InvalidQueryParameter | %s | |
| 400 | IllegalAddress | Illegal HTTP address | |
| 400 | OperationError | Operation failed | |
| 400 | TaskNotExists | Task does not exist | |
| 400 | OperatorInvalid | Operator invalid | |
| 400 | NameRepeat | Task name repeat | |
| 400 | CreateAlarmError | Create alarm error | |
| 400 | NameNotExists | Task name not exists | |
| 400 | OperatorCityInvalid | Invalid Isp. | Invalid Isp |
| 401 | AccessDeniedException | You donot have sufficient access to perform this action. | |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 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 | |
| 503 | %s | %s | |
| 406 | ExceedingQuota | Exceeding quota limits. | The number of tasks exceeds the limit |
| 409 | %s | %s |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.