指标 API 参考
获取所有指标
端点:
GET /v1/:page_id/metrics?page=:page&per_page=:per_page
- page 默认为 1。
- per_page 默认为 50,每页最多 100 条。
响应示例:
[{"id": "ckj1qyonq9sdk09819xdg4ehm","name": "Testing","active": true,"order": 1,"suffix": "ms","data": [{"timestamp": 1608474985000,"value": 355},{"timestamp": 1608475225000,"value": 428.25},{"timestamp": 1608475465000,"value": 356},{"timestamp": 1608475705000,"value": 451.75},...]},...]
获取单个指标
端点:
GET /v1/:page_id/metrics/:metric_id
响应示例:
{"id": "ckj1qyonq9sdk09819xdg4ehm","name": "Testing","active": true,"order": 1,"suffix": "ms","data": [{"timestamp": 1608474985000,"value": 355},{"timestamp": 1608475225000,"value": 428.25},{"timestamp": 1608475465000,"value": 356},{"timestamp": 1608475705000,"value": 451.75},...]}
添加指标
端点:
POST /v1/:page_id/metrics
{"subdomain": "nasa","name": "Response time","suffix": "ms"}
响应示例:
{"id": "ckj1qyonq9sdk09819xdg4ehm","name": "Response time","active": true,"order": 1,"suffix": "ms","lastDataAt": 1608561235000,"data": [{"timestamp": 1608474985000,"value": 355},{"timestamp": 1608475225000,"value": 428.25},{"timestamp": 1608475465000,"value": 356},...]}
更新指标
端点:
PUT /v1/:page_id/metrics/:metric_id
请求示例:
{"name": "Response time","suffix": "ms"}
响应示例:
{"id": "ckj1qyonq9sdk09819xdg4ehm","name": "Response time","active": true,"order": 1,"suffix": "ms","lastDataAt": 1608561235000,"data": [{"timestamp": 1608474985000,"value": 355},{"timestamp": 1608475225000,"value": 428.25},{"timestamp": 1608475465000,"value": 356},...]}
删除指标
端点:
DELETE /v1/:page_id/metrics/:metric_id
向指标添加一个数据点
端点:
POST /v1/:page_id/metrics/:metric_id
请求:
{"timestamp": 1608672985000,"value": 356}
响应:
{"id": "ckj395ptx9ha40995ckzv0pz2","value": 356,"timestamp": 1608672985000}
向指标添加多个数据点
端点:
POST /v1/:page_id/metrics/:metric_id/data
请求:
{"data": [{"timestamp": 1608474985000,"value": 355},{"timestamp": 1608475225000,"value": 428.25},{"timestamp": 1608475465000,"value": 356},{"timestamp": 1608475705000,"value": 451.75},{"timestamp": 1608475945000,"value": 395},{"timestamp": 1608476185000,"value": 375.75},{"timestamp": 1608476425000,"value": 380.25},...]}
响应
[{"timestamp": 1608474985000,"value": 355},{"timestamp": 1608475225000,"value": 428.25},{"timestamp": 1608475465000,"value": 356},{"timestamp": 1608475705000,"value": 451.75},{"timestamp": 1608475945000,"value": 395},{"timestamp": 1608476185000,"value": 375.75},{"timestamp": 1608476425000,"value": 380.25}]
删除指标的数据点
端点:
DELETE /v1/:page_id/metrics/:metric_id/data
响应
{"name": "Response time","site": {"id": "ckj1qyonq9sdk09819xdg4ehm","subdomain": "our"}}