Cloud Test 公用接口说明文档
一.获取监控指定日期的日报
1.URL
https://ct.aiops.com/synthetic/api/v1/report/day.json
2.HTTP请求方式
POST /synthetic/api/v1/report/day.json
3.访问频率限制
1次/2分钟
4.请求参数(json格式):
1. monitorId <int> 监控项目ID 必填 2. date <string> 日期,格式为YYYY-MM-DD,比如2016-05-16 必填 3. accessToken <string> 授权口令 必填
5.返回结果
不同类型监控的报表数据格式有所差异,请注意!!
单页面、api、事务报表
{ "monitorId": 59, // 监控id "description": "OneAPM 官网", // 监控名称 "type": "single", // single | api | transaction "reportOverviews": [{ "name": "北京联通_大兴区", // 监控节点名称 "available": 142, // 可用次数 "avgResponseTime": 1066.33, // 平均响应时间 ms "responseTime": 151419.0, // 总响应时间 "error": 0, // 总错误次数 "availableRate": 1.0, // 可用率 "errorRate": 0.0, // 错误率 "total": 142 // 监控次数 }], "performances": [{ "name": "北京联通_大兴区", // 监控节点名称 "avgRespTime": 18.32, // 内容下载时间 "avgDnsTime": 50.59, // DNS时间 "avgFirstByteTime": 47.75, // 后端响应时间 "avgConnectTime": 17.21, // 建立连接时间 "totalTime": 133.87 // 总时间 }], "errorTypes": [{ "name": "北京联通_大兴区", "netError": 0, // 网络错误次数 "httpError": 0, // HTTP错误次数 "error": 0, // 总错误次数 "timeoutError": 0, // 超时错误次数 "responseCodeError": 0, // Code应答错误次数 "responseTimeError": 0, // 时间应答错误次数 "contentMatchError": 0, // 内容匹配错误次数 "scriptError": 0 // 脚本错误次数 }] }
ping 报表
{ "monitorId": 2104, "description": "OneAPM Ping", "type": "ping", "reportOverviews": [{ "name": "北京联通_大兴区", "avgResponseTime": 248.55, "availableRate": 0.9965, "packetLossRate": 0.0355, // 丢包率 "responseTime": 71333.0, "available": 287, "sentTimes": 1435, // 传送包次数 "receivedTimes": 1384, // 收到包次数 "total": 288 }] }
dns 报表
{ "monitorId": 3627, "description": "OneAPM DNS", "type": "dns", "reportOverviews": [{ "name": "北京联通_大兴区", "available": 720, "avgResponseTime": 28.72, "responseTime": 20676.0, "error": 0, "availableRate": 1.0, "errorRate": 0.0, "total": 720 }], "errorTypes": [{ "name": "北京联通_大兴区", "error": 0, "contentError": 0, // 匹配错误 "resolveError": 0 // 解析错误 }] }
错误返回值格式:
{"status":"ERROR","content":{"code":401,"message":"AccessToken is nonexistent or invalid"}}
常见错误码详细解释见页底。
二.获取监控指定日期的周报
URL:
https://ct.aiops.com/synthetic/api/v1/report/week.json
HTTP请求方式:
POST /synthetic/api/v1/report/week.json
访问频率限制:
1次/2分钟
请求参数(json格式):
1. monitorId <int> 监控项目ID 必填 2. date <string> 格式为YYYY-MM-DD如2016-05-16,该日期必须是周一,返回2015-05-16到2016-05-22的数据 必填 3. accessToken <string> 授权口令 必填
返回结果:
不同类型监控的报表数据格式有所差异,请注意!!
单页面、api、事务报表
{ "monitorId": 59, // 监控id "description": "OneAPM 官网", // 监控名称 "type": "single", // single | api | transaction "reportOverviews": [{ "name": "北京联通_大兴区", // 监控节点名称 "available": 142, // 可用次数 "avgResponseTime": 1066.33, // 平均响应时间 ms "responseTime": 151419.0, // 总响应时间 "error": 0, // 总错误次数 "availableRate": 1.0, // 可用率 "errorRate": 0.0, // 错误率 "total": 142 // 监控次数 }], "performances": [{ "name": "北京联通_大兴区", // 监控节点名称 "avgRespTime": 18.32, // 内容下载时间 "avgDnsTime": 50.59, // DNS时间 "avgFirstByteTime": 47.75, // 后端响应时间 "avgConnectTime": 17.21, // 建立连接时间 "totalTime": 133.87 // 总时间 }], "errorTypes": [{ "name": "北京联通_大兴区", "netError": 0, // 网络错误次数 "httpError": 0, // HTTP错误次数 "error": 0, // 总错误次数 "timeoutError": 0, // 超时错误次数 "responseCodeError": 0, // Code应答错误次数 "responseTimeError": 0, // 时间应答错误次数 "contentMatchError": 0, // 内容匹配错误次数 "scriptError": 0 // 脚本错误次数 }] }
ping 报表
{ "monitorId": 2104, "description": "OneAPM Ping", "type": "ping", "reportOverviews": [{ "name": "北京联通_大兴区", "avgResponseTime": 248.55, "availableRate": 0.9965, "packetLossRate": 0.0355, // 丢包率 "responseTime": 71333.0, "available": 287, "sentTimes": 1435, // 传送包次数 "receivedTimes": 1384, // 收到包次数 "total": 288 }] }
dns 报表
{ "monitorId": 3627, "description": "OneAPM DNS", "type": "dns", "reportOverviews": [{ "name": "北京联通_大兴区", "available": 720, "avgResponseTime": 28.72, "responseTime": 20676.0, "error": 0, "availableRate": 1.0, "errorRate": 0.0, "total": 720 }], "errorTypes": [{ "name": "北京联通_大兴区", "error": 0, "contentError": 0, // 匹配错误 "resolveError": 0 // 解析错误 }] }
错误返回值格式:
{"status":"ERROR","content":{"code":401,"message":"AccessToken is nonexistent or invalid"}}
常见错误码详细解释见页底。
三.获取Ct列表页的数据
URL:
https://ct.aiops.com/synthetic/api/v1/monitor/list.json
HTTP请求方式:
POST /synthetic/api/v1/monitor/list.json
访问频率限制:
1次/2分钟
请求参数(json格式):
accessToken <string> 授权口令 必填
返回结果:
[{ "id": 100094, // 监控id "description": "OneAPM 官网", // 监控名称 "type": "single", // 监控类型 single | api | transaction | ping | dns "status": "active", // 监控状态 active | delete | inactive "url": "http://www.oneapm.com", // 监控URL "avgResponseTime": 33.6986, // 三个小时内的平均响应时间 "availableRate": 0.0, // 三个小时内的可用率 "displayType": "单页面监控" // 监控类型名称 }, { "id": 100108, "description": "www.baidu.com", "type": "api", "status": "active", "url": "http://www.baidu.com", "avgResponseTime": 147.114, "availableRate": 0.0, "displayType": "API 监控" }, { "id": 100111, "description": "公司官网", "type": "transaction", "status": "active", "url": "www.oneapm.com.json", "avgResponseTime": 55777.94, "availableRate": 0.9423077, "displayType": "事务监控" }, { "id": 100095, "description": "ping监控", "type": "ping", "status": "active", "url": "www.baidu.com", "avgResponseTime": 16.8387, "availableRate": 1.0, "displayType": "PING 监控" }, { "id": 100129, "description": "dns监控回归验证", "type": "dns", "status": "active", "url": "www.qq.com", "avgResponseTime": 2097.7058, "availableRate": 0.99124724, "displayType": "DNS 监控" }]
错误返回值格式:
{"status":"ERROR","content":{"code":401,"message":"AccessToken is nonexistent or invalid"}}
常见错误码详细解释见页底。
四.常见错误码详细解释
400 Request too frequently // 请求过于频繁 401 AccessToken is nonexistent or invalid // accessToken不存在 403 Permission Denied // 请求的资源不属于该用户 405 Request method not supported // 请求方法对指定的资源不适用 410 No result // 没有结果 412 Incorrect parameter type // 参数类型错误 500 Server error // 服务器未知错误