# Get all usage graphs

`GET https://console.advinservers.com/api/v1/client/servers/{server}/metrics`

### Overview

Returns CPU, memory, disk and network graphs. `period` accepts `hour`, `day`, `week`, `month` or `year` and defaults to `hour`. `aggregation` accepts `average` or `maximum` and defaults to `average`. Use `maximum` to see short usage spikes. Missing readings return 200 with an `unavailable` message and empty series. A stopped server may also have empty series.

### Permissions

Requires the `server.read` (View servers) permission for the selected team. Resources outside that team return 404.

## Authorization

Send `Authorization: Bearer <token>` with the request. Your API key, sent as a bearer token. Create one in the control panel under API Keys, give it only the permissions the integration needs, and copy it when it is created. It cannot be shown again. Each key is restricted to one owned team. The key determines the team for every request.

## Path parameters

- `server` (string, required): The server uuid short

## Query parameters

- `period` (string | null): The value of `period`. One of: `hour`, `day`, `week`, `month`, `year`.
- `aggregation` (string | null): The value of `aggregation`. One of: `average`, `maximum`.

## Response 200

The record, as a JSON object. There is no envelope.

- `period` (string, required): The window the series cover, counted back from now. One of: `hour`, `day`, `week`, `month`, `year`.
- `aggregation` (string, required): How the samples inside each bucket of the series were consolidated. One of: `average`, `maximum`.
- `unavailable` (string | null, required): Null when the series below were read, and a sentence saying so when they could not be.
- `series` (object, required): The value of `series`.
  - `cpu` (object | array[], required): The value of `cpu`.
  - `mem` (object | array[], required): The value of `mem`.
  - `disk` (object | array[], required): The value of `disk`.
  - `net` (object | array[], required): The value of `net`.

```json
{
  "period": "hour",
  "aggregation": "average",
  "unavailable": null,
  "series": {
    "cpu": [
      {
        "time": 1789403880,
        "cpu": 0.25
      },
      {
        "time": 1789403940,
        "cpu": 0.31
      },
      {
        "time": 1789404000,
        "cpu": 0.22
      }
    ],
    "mem": [
      {
        "time": 1789403880,
        "mem": 2147483648
      },
      {
        "time": 1789403940,
        "mem": 2181038080
      },
      {
        "time": 1789404000,
        "mem": 2164260864
      }
    ],
    "disk": [
      {
        "time": 1789403880,
        "diskread": 24576,
        "diskwrite": 186368
      },
      {
        "time": 1789403940,
        "diskread": 8192,
        "diskwrite": 241664
      },
      {
        "time": 1789404000,
        "diskread": 16384,
        "diskwrite": 163840
      }
    ],
    "net": [
      {
        "time": 1789403880,
        "netin": 412876,
        "netout": 1893120
      },
      {
        "time": 1789403940,
        "netin": 398212,
        "netout": 2011648
      },
      {
        "time": 1789404000,
        "netin": 455190,
        "netout": 1768448
      }
    ]
  }
}
```

## Errors

- `401`: The key was missing, malformed, revoked, or belongs to an account that no longer exists.
- `403`: Access denied. Check the key's team, permissions and allowed IP addresses. Some actions, such as managing API keys, require a browser session. The response message explains the reason.
- `404`: The resource was not found in the selected team. Resources in another account or team also return 404.
- `422`: The requested period or aggregation is invalid.
- `429`: Too many requests. The `Retry-After` header says how many seconds to wait. Limits are per account, so several keys on one account share them.

## Example request

```bash
curl --request GET \
  --url 'https://console.advinservers.com/api/v1/client/servers/{server}/metrics' \
  --header 'Authorization: Bearer <token>' \
  --header 'Accept: application/json'
```
