Creates a site monitoring task.

Site monitoring supports the following protocols: HTTP, PING, TCP, UDP, DNS, SMTP, POP3, and FTP. Each protocol has a specific set of extended options specified by the OptionsJson parameter. The following tables describe the extended options supported for each protocol.

HTTP

Parameter

Type

Description

http_method

String

The request method. Valid values: GET, POST, and HEAD. Default value: GET.

header

String

The HTTP request header. The HTTP request header consists of key-value pairs. Separate the key-value pairs with newline characters ("\n"). Separate the key and value in each pair with a colon (:).

cookie

String

The HTTP cookie. Specify the HTTP cookie in compliance with the HTTP request standard.

request_content

String

The content of the request. The content can be in JSON or form format. If this parameter is not specified, the request has no body.

response_content

String

The expected or unexpected content of the response. The first 64 KB of the content returned from the HTTP server will be checked during site monitoring.

match_rule

String

The match rule. The value 0 indicates that the detection is successful if the response does not contain the unexpected content specified by the response_content parameter. The value 1 indicates that the detection is successful if the response contains the expected content specified by the response_content parameter.

username

String

The username used to authenticate the HTTP request. If this parameter is specified, the HTTP request will contain the basic authentication header.

password

String

The password used to authenticate the HTTP request.

time_out

Integer

The timeout period. Unit: milliseconds. Default value: 5000.

max_redirect

Integer

The maximum number of redirections. The default value is 5 for a detection point provided by Alibaba Cloud and 2 for a detection point provided by a carrier. To disable redirections, set the value to 0. Valid values: 0 to 50.

PING

Parameter

Type

Description

failure_rate

Integer

The failure rate threshold. If the failure rate exceeds this threshold, the detection fails and the status code 610 (PingAllFail) or 615 (PingPartialFail) is returned. Default value: 0.1.

ping_num

Integer

The number of times that the monitored address is pinged. Default value: 20. 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 DNS records to query. Valid values: A, NS, CNAME, MX, TXT, and ANY.

expect_value

String

The expected value list, consisting of the IP addresses to be obtained after DNS resolution. Separate IP addresses with space characters.

match_rule

String

The relationship between the expected value list and the returned value list after DNS resolution. If the two lists do not meet the specified relationship, the detection fails. Valid values:

Empty string or IN_DNS: The expected value list is a subset of the returned value list.

DNS_IN: The returned value list is a subset of the expected value list.

EQUAL: The returned value list is the same as the expected value list.

ANY: the returned value list intersects with the expected value list.

FTP

Parameter

Type

Description

port

Integer

The port number of the FTP server. If this parameter is not specified, the default port number is used. The default port number is 21 for FTP and 990 for FTPS.

username

String

The username used to log on to the FTP server. If this parameter is not specified, anonymous logon is used.

password

String

The password used to log on to the FTP server.

POP3 or SMTP

Parameter

Type

Description

port

Integer

The port number of the POP3 server. The default port number is 110 for the POP3 protocol and 995 for the POP3S protocol.

username

String

The username used to log on to the server.

password

String

The password used to log on to the server.

TCP or UDP

Parameter

Type

Description

port

Integer

The TCP or UDP port to monitor.

request_content

String

The content of the request. If the request_format parameter is set to hex, the value of the request_content parameter must be in hexadecimal format.

request_format

String

The format of the request content. If the request_format parameter is not set to hex, the value of the request_content parameter will be sent to the server as common text.

response_content

String

The expected or unexpected content of the response. If the response from the server does not contain the expected 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 must be in hexadecimal format. If the response_format parameter is not set to hex, the server considers the value of the response_content parameter as common text.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateSiteMonitor

The operation that you want to perform. Set the value to CreateSiteMonitor.

Address String Yes http://www.aliyun.com

The URL or IP address monitored by the site monitoring task.

TaskName String Yes Website monitoring

The name of the site monitoring task. The name can be 4 to 100 characters in length. It can contain letters, digits, and underscores (_).

TaskType String Yes HTTP

The protocol used by the site monitoring task. Valid values: HTTP, PING, TCP, UDP, DNS, SMTP, POP3, and FTP.

Interval String No 1

The interval at which detection requests are sent. Valid values: 1, 5, and 15. Unit: minutes. Default value: 1.

IspCities String No [{"city":"546","isp":"465"},{"city":"572","isp":"465"},{"city":"738","isp":"465"}]

The information about detection points, which is specified in a JSON array. Example: [{"city":"546","isp":"465"},{"city":"572","isp":"465"},{"city":"738","isp":"465"}]. The three city codes respectively represent Beijing, Hangzhou, and Qingdao. You can call the DescribeSiteMonitorISPCityList operation to query the detection points that are available for creating site monitoring tasks. If this parameter is not specified, the system randomly select three detection points for site monitoring.

OptionsJson String No {"time_out":5000}

The extended options of the protocol used by the site monitoring task. The options vary based on the protocol.

AlertIds String No 49f7c317-7645-4cc9-94fd-ea42e122****

The ID of an existing alert rule to be associated with the site monitoring task. You can call the DescribeMetricRuleList operation to obtain the IDs of existing alert rules.

Response parameters

Parameter Type Example Description
AlertRule String [{"alarmActions":["Default alert group"],"metricName":"Availability","expression":"$Availability<96"}]

The alert rule configured for the site monitoring task. The value is a JSON array in the following format:

[{"alarmActions":["xxx"],"metricName":"Availability","expression":"$Availability<96"}].

  • alarmActions: the alert group to which alert notifications are sent.
  • metricName: the name of the metric for triggering alerts. Valid values:

    -Availability: the percentage of detection results in which the status code is smaller than 400.

    -AvailableNumber: the number of detection results in which the status code is smaller than 400.

Code String 200

The HTTP status code.

Note The status code 200 indicates that the call was successful.
Data Struct N/A

The creation result of the site monitoring task.

AttachAlertResult Array N/A

The result of associating the existing alert rule with the site monitoring task.

Contact N/A N/A N/A
Code String 200

The HTTP status code returned after a request was sent for associating the existing alert rule with the site monitoring task.

Note The status code 200 indicates that the call was successful.
Message String success

The message returned after a request was sent for associating the existing alert rule with the site monitoring task.

RequestId String 32565d-233-1b98-2231-892813f86c71

The ID of the request for associating the existing alert rule with the site monitoring task.

RuleId String ruleId12345

The ID of the existing alert rule that was associated with the site monitoring task.

Success String true

Indicates whether the existing alert rule was associated with the site monitoring task.

Message String Successfully

The returned message.

RequestId String 68192f5d-0d45-4b98-9724-892813f86c71

The ID of the request.

Success String true

Indicates whether the call was successful. The value true indicates a success. The value false indicates a failure.

Examples

Sample requests

http(s)://[Endpoint]/? Action=CreateSiteMonitor
&Address=http://www.aliyun.com
&TaskName=Website monitoring
&TaskType=HTTP
&<Common request parameters>

Sample success responses

XML format

<CreateSiteMonitorResponse>
    <RequestId>04F0F334-1335-436C-A1D7-6C044FE73368</RequestId>
    <Success>true</Success>
    <Code>200</Code>
    <Message>Successfully</Message>
</CreateSiteMonitorResponse>

JSON format

{
    "Message":"Successfully",
    "Success": true,
    "Code": "200"
}

Error codes

For a list of error codes, visit the API Error Center.