Referência da API de métricas

Obter todas as métricas

Endpoint:

GET /v1/:page_id/metrics?page=:page&per_page=:per_page
  • O número de página padrão é 1.
  • O per_page padrão é 50 e o máximo é 100 itens por página.

Exemplo de resposta:

[
{
"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
},
...
]
},
...
]

Obter uma métrica

Endpoint:

GET /v1/:page_id/metrics/:metric_id

Exemplo de resposta:

{
"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
},
...
]
}

Adicionar uma métrica

Endpoint:

POST /v1/:page_id/metrics
{
"subdomain": "nasa",
"name": "Response time",
"suffix": "ms"
}

Exemplo de resposta:

{
"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
},
...
]
}

Atualizar uma métrica

Endpoint:

PUT /v1/:page_id/metrics/:metric_id

Exemplo de requisição:

{
"name": "Response time",
"suffix": "ms"
}

Exemplo de resposta:

{
"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
},
...
]
}

Excluir uma métrica

Endpoint:

DELETE /v1/:page_id/metrics/:metric_id

Adicionar um ponto de dados a uma métrica

Endpoint:

POST /v1/:page_id/metrics/:metric_id

Requisição:

{
"timestamp": 1608672985000,
"value": 356
}

Resposta:

{
"id": "ckj395ptx9ha40995ckzv0pz2",
"value": 356,
"timestamp": 1608672985000
}

Adicionar vários pontos de dados a uma métrica

Endpoint:

POST /v1/:page_id/metrics/:metric_id/data

Requisição:

{
"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
},
...
]
}

Resposta

[
{
"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
}
]

Excluir pontos de dados de uma métrica

Endpoint:

DELETE /v1/:page_id/metrics/:metric_id/data

Resposta

{
"name": "Response time",
"site": {
"id": "ckj1qyonq9sdk09819xdg4ehm",
"subdomain": "our"
}
}