Get metrics
GET/api/v1/vms/{vm_uuid}/metrics
CPU, disk and network from the host side, averaged over each point, for the window you ask for.
Parameters
| Name | In | Description |
|---|---|---|
| vm_uuid | path, stringrequired | Server id, from Create a VM or List VMs |
| window | query, string | 5m, 15m, 30m, 1h, 2h, 6h, 12h, 24h, 3d, 7d or 30d; 1h when left out |
Example request
curl -X GET "https://platform.serverscamp.com/api/v1/vms/$VM_UUID/metrics?window=1h" \
-H "Authorization: Bearer $API_TOKEN"import os, requests
token = os.environ["API_TOKEN"]
vm_uuid = "6f1c2a9e-4b3d-4e8a-9c71-2d5e8f0a1b34"
r = requests.get(
f"https://platform.serverscamp.com/api/v1/vms/{vm_uuid}/metrics?window=1h",
headers={"Authorization": f"Bearer {token}"},
)
r.raise_for_status()
print(r.json())const vmUuid = '6f1c2a9e-4b3d-4e8a-9c71-2d5e8f0a1b34';
const r = await fetch(`https://platform.serverscamp.com/api/v1/vms/${vmUuid}/metrics?window=1h`, {
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 |
|---|---|---|
| vm_uuid | stringrequired | |
| window | stringrequired | The window asked for |
| resolution_seconds | integerrequired | Seconds each point averages |
| current | VmMetricsPoint, optional | The latest reading |
| current.ts | integerrequired | Unix time of the point |
| current.cpu_pct | number, optional | CPU in use, percent of all the server's vCPUs |
| current.disk_rd_iops | number, optional | Disk reads a second |
| current.disk_wr_iops | number, optional | Disk writes a second |
| current.disk_rd_bps | number, optional | Disk reads, bytes a second |
| current.disk_wr_bps | number, optional | Disk writes, bytes a second |
| current.rx_bps | number, optional | Traffic into the server, bytes a second |
| current.tx_bps | number, optional | Traffic out of the server, bytes a second |
| points | list of VmMetricsPointrequired | From the host side, oldest first |
| points[].ts | integerrequired | Unix time of the point |
| points[].cpu_pct | number, optional | CPU in use, percent of all the server's vCPUs |
| points[].disk_rd_iops | number, optional | Disk reads a second |
| points[].disk_wr_iops | number, optional | Disk writes a second |
| points[].disk_rd_bps | number, optional | Disk reads, bytes a second |
| points[].disk_wr_bps | number, optional | Disk writes, bytes a second |
| points[].rx_bps | number, optional | Traffic into the server, bytes a second |
| points[].tx_bps | number, optional | Traffic out of the server, bytes a second |
{
"vm_uuid": "6f1c2a9e-4b3d-4e8a-9c71-2d5e8f0a1b34",
"window": "1h",
"resolution_seconds": 60,
"current": {
"ts": 1793532000,
"cpu_pct": 7.4,
"disk_rd_iops": 3,
"disk_wr_iops": 41,
"disk_rd_bps": 12288,
"disk_wr_bps": 409600,
"rx_bps": 18432,
"tx_bps": 92160
},
"points": [
{
"ts": 1793531940,
"cpu_pct": 6.9,
"disk_rd_iops": 2,
"disk_wr_iops": 38,
"disk_rd_bps": 8192,
"disk_wr_bps": 389120,
"rx_bps": 17408,
"tx_bps": 88064
}
]
}Errors
| Status | When |
|---|---|
400 | Not one of the windows |
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