Referencia de la API de métricas
Obtener todas las métricas
Endpoint:
GET /v1/:page_id/metrics?page=:page&per_page=:per_page
- El número de página por defecto es 1.
- El valor por defecto de per_page es 50 y el máximo es de 100 elementos por página.
Respuesta de ejemplo:
[{"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},...]},...]
Obtener una métrica
Endpoint:
GET /v1/:page_id/metrics/:metric_id
Respuesta de ejemplo:
{"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},...]}
Añadir una métrica
Endpoint:
POST /v1/:page_id/metrics
{"subdomain": "nasa","name": "Response time","suffix": "ms"}
Respuesta de ejemplo:
{"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},...]}
Actualizar una métrica
Endpoint:
PUT /v1/:page_id/metrics/:metric_id
Petición de ejemplo:
{"name": "Response time","suffix": "ms"}
Respuesta de ejemplo:
{"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},...]}
Eliminar una métrica
Endpoint:
DELETE /v1/:page_id/metrics/:metric_id
Añadir un punto de datos a una métrica
Endpoint:
POST /v1/:page_id/metrics/:metric_id
Petición:
{"timestamp": 1608672985000,"value": 356}
Respuesta:
{"id": "ckj395ptx9ha40995ckzv0pz2","value": 356,"timestamp": 1608672985000}
Añadir varios puntos de datos a una métrica
Endpoint:
POST /v1/:page_id/metrics/:metric_id/data
Petición:
{"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},...]}
Respuesta
[{"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}]
Eliminar puntos de datos de una métrica
Endpoint:
DELETE /v1/:page_id/metrics/:metric_id/data
Respuesta
{"name": "Response time","site": {"id": "ckj1qyonq9sdk09819xdg4ehm","subdomain": "our"}}