Get metrics
GET/api/v1/vps/{vps_uuid}/metrics
CPU, memory, network, disk and pressure from the host side, averaged over each point, for the last hour, day or week. A new server has no history before it was created.
Parameters
| Name | In | Description |
|---|---|---|
| vps_uuid | path, stringrequired | VPS id, from Create a VPS or List VPS |
| timeframe | query, string |
Example request
curl -X GET "https://platform.serverscamp.com/api/v1/vps/$VPS_UUID/metrics?timeframe=hour" \
-H "Authorization: Bearer $API_TOKEN"import os, requests
token = os.environ["API_TOKEN"]
vps_uuid = "12d46f8c-d66e-4163-99aa-1245d5b06e5b"
r = requests.get(
f"https://platform.serverscamp.com/api/v1/vps/{vps_uuid}/metrics?timeframe=hour",
headers={"Authorization": f"Bearer {token}"},
)
r.raise_for_status()
print(r.json())const vpsUuid = '12d46f8c-d66e-4163-99aa-1245d5b06e5b';
const r = await fetch(`https://platform.serverscamp.com/api/v1/vps/${vpsUuid}/metrics?timeframe=hour`, {
method: 'GET',
headers: { Authorization: `Bearer ${process.env.API_TOKEN}` },
});
console.log(r.status, await r.json());Answer
Status 200 with this body.
| Field | Type | Description |
|---|---|---|
| timeframe | one of hour, day, weekrequired | |
| points | list of VpsMetricsPointrequired | From the host side; null where the server was off |
| points[].t | integerrequired | Unix time of the point |
| points[].cpu | number, optional | Share of all the server's vCPUs in use, 0 to 1 |
| points[].mem | number, optional | Memory the server takes, bytes |
| points[].maxmem | number, optional | Memory of the plan, bytes |
| points[].netin | number, optional | Traffic into the server, bytes a second |
| points[].netout | number, optional | Traffic out of the server, bytes a second |
| points[].diskread | number, optional | Disk reads, bytes a second |
| points[].diskwrite | number, optional | Disk writes, bytes a second |
| points[].pressurecpusome | number, optional | Share of time some programs waited for CPU, percent |
| points[].pressurecpufull | number, optional | Share of time all programs waited for CPU, percent |
| points[].pressurememorysome | number, optional | The same for memory, some programs |
| points[].pressurememoryfull | number, optional | The same for memory, all programs |
| points[].pressureiosome | number, optional | The same for disk, some programs |
| points[].pressureiofull | number, optional | The same for disk, all programs |
{
"timeframe": "hour",
"points": [
{
"t": 1792656000,
"cpu": 0.0312,
"mem": 412311552,
"maxmem": 805306368,
"netin": 1843.2,
"netout": 9216.5,
"diskread": 0,
"diskwrite": 40960,
"pressurecpusome": 0.41,
"pressurecpufull": 0,
"pressurememorysome": 0,
"pressurememoryfull": 0,
"pressureiosome": 0.12,
"pressureiofull": 0.05
}
]
}Errors
| Status | When |
|---|---|
400 | timeframe is not hour, day or week |
401 | No token, or a token that is not valid |
422 | The body or a parameter is not what the operation takes |
Every operation can also answer 401 without a valid token. All errors