Get a server's graphs
/v1/servers/{serverId}/metrics The server's graphs over a time range: processor, memory and disk use in percent, load, and bandwidth in and out. Each graph is a list of readings (t in Unix seconds). They're empty while the server isn't running; a new server's history fills in over its first minutes (notice says so).
Scopes
The token needs this scope. Without it, the request is refused with insufficient_scope (see Scopes).
-
servers:read - View servers. See servers, their graphs, snapshots, logs and security (Imunify360).
Path parameters
| Field | Type and description |
|---|---|
serverId Required | string The server's id. |
Query parameters
| Field | Type and description |
|---|---|
range | string Default The time the graphs cover: One of: |
Example request
curl "https://api.rabbitflare.com/v1/servers/3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d/metrics?range=1h" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" const res = await fetch("https://api.rabbitflare.com/v1/servers/3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d/metrics?range=1h", {
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
},
});
if (!res.ok) throw new Error(`Rabbitflare API error ${res.status}: ${await res.text()}`);
const { data } = await res.json();
console.log(data); import { Rabbitflare } from "@rabbitflare/api";
const rf = new Rabbitflare({ token: process.env.RABBITFLARE_TOKEN });
const data = await rf.servers.metrics.get({
serverId: "3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d",
range: "1h",
});
console.log(data); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/servers/3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d/metrics?range=1h');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status >= 400) {
throw new RuntimeException("Rabbitflare API error $status: $body");
}
print_r(json_decode($body, true)['data']); import os
import requests
response = requests.get(
"https://api.rabbitflare.com/v1/servers/3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d/metrics",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
params={
"range": "1h",
},
timeout=120,
)
response.raise_for_status()
print(response.json()["data"]) Response
200 OK Returns the ServerMetrics object in data.
The ServerMetrics object's fields 20 fields
| Field | Type and description |
|---|---|
range | string The time the graphs cover: Known values: |
cpu | array of objects Processor use, in percent (0 to 100). |
t | integer The time of the reading, in Unix seconds. |
v | number The reading. |
memory | array of objects Memory in use, in percent. |
t | integer The time of the reading, in Unix seconds. |
v | number The reading. |
disk | array of objects Disk space in use, in percent. |
t | integer The time of the reading, in Unix seconds. |
v | number The reading. |
load | array of objects The load average over one minute. |
t | integer The time of the reading, in Unix seconds. |
v | number The reading. |
bandwidthIn | array of objects Data received, in megabits per second. |
t | integer The time of the reading, in Unix seconds. |
v | number The reading. |
bandwidthOut | array of objects Data sent, in megabits per second. |
t | integer The time of the reading, in Unix seconds. |
v | number The reading. |
notice | string or null A note about the graphs, for example while a new server's history is still being collected. Null when there's none. |
Example response
{
"data": {
"range": "1h",
"cpu": [
{
"t": 1763455200,
"v": 12.4
}
],
"memory": [
{
"t": 1763455200,
"v": 41.7
}
],
"disk": [
{
"t": 1763455200,
"v": 21.3
}
],
"load": [
{
"t": 1763455200,
"v": 0.18
}
],
"bandwidthIn": [
{
"t": 1763455200,
"v": 0.42
}
],
"bandwidthOut": [
{
"t": 1763455200,
"v": 1.35
}
],
"notice": null
}
} Errors
The errors this request can answer besides those every request can (a missing token, a missing scope, the rate limits). Each answer is an Error object (see Errors).
| Status and code | When, and what to do |
|---|---|
400 invalid_ | A query parameter is unknown or has a wrong value ( Correct or remove the parameter named in |
404 not_ | The resource doesn't exist, or isn't this account's. Check the id. Ids of other accounts' resources answer the same way. |
409 server_ | The server is being restored, and nothing else can change it or its sites until that's done. Wait until the restore finishes (the server's |
502 server_ | The server didn't answer, or didn't finish the request. Check that the server is running, then try again in a minute. |