> ## Documentation Index
> Fetch the complete documentation index at: https://www.agent37.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Read metrics

> Fetch an instance's CPU, memory, and disk history to see whether it is sized right, spot leaks, and know before it hits a limit.

`GET /v1/instances/{id}/metrics` returns up to 14 days of resource history: CPU cores in use, memory bytes, and disk bytes, sampled about once a minute on the host, alongside the instance's configured limits. Where [logs](https://www.agent37.com/docs/agents-api/logs.md) answer "what did it print", metrics answer "is it running out of something": a memory line creeping toward its limit, CPU pinned at the cap, or a disk filling up.

Samples start landing a couple of minutes after an instance first runs, so a just-created instance answers `200` with empty series at first. While an instance is `sleeping` or `stopped` there is no live container to measure: CPU and memory show gaps for those periods, and only disk keeps reporting.

## Request

**hours** `integer` (default: 24)

The window to return, ending now. Defaults to 24, capped at 336 (14 days, which is also the retention). A value that is not an integer in range returns `400 invalid_request`.

## Response

**series** `object`

Three time series, each an array of `[unixSeconds, value]` pairs in ascending time order.

**series**

**cpu\_cores** `array`

CPU in use, in cores (for example `0.4` on a 2-vCPU instance means 20% of one core). Compare against `limits.cpu_cores`.

**memory\_bytes** `array`

Memory in use, in bytes. Empty on a `vm` or `performance` instance: read it inside the machine, for example `free -m` over [exec](https://www.agent37.com/docs/agents-api/exec.md).

**disk\_bytes** `array`

Disk used by the instance's data volume, in bytes.

**limits** `object`

The instance's configured shape in the same units: `cpu_cores`, `memory_bytes`, `disk_bytes`. Chart these as ceilings over the series.

**hours** `integer`

The window that was returned.

**step\_seconds** `integer`

Spacing between points. It widens with the window (60s at one hour, coarser at 14 days) so any range returns a chart-sized payload of a few hundred points.

**fetched\_at** `integer`

When the query ran, in epoch seconds.

Unknown, deleted, or other-workspace ids return `404 not_found`. If the metrics store is unreachable, you get `503 try_again`; retry shortly.

## Example

```bash curl wrap theme={null}
curl -X GET \
  https://api.agent37.com/v1/instances/ab12cd34ef/metrics \
  --url-query "hours=24" \
  -H "Authorization: Bearer sk_live_..."
```

```python Python wrap theme={null}
import requests

response = requests.get(
    "https://api.agent37.com/v1/instances/ab12cd34ef/metrics",
    headers={
        "Authorization": "Bearer sk_live_..."
    },
    params={
        "hours": 24
    },
)
response.raise_for_status()
print(response.json())
```

```javascript Node wrap theme={null}
const query = new URLSearchParams({
  "hours": "24"
});

const response = await fetch(
  "https://api.agent37.com/v1/instances/ab12cd34ef/metrics" + "?" + query,
  {
    method: "GET",
    headers: {
      "Authorization": "Bearer sk_live_..."
    },
  },
);
if (!response.ok) {
  throw new Error(await response.text());
}
console.log(await response.json());
```

```json response wrap theme={null}
{
  "series": {
    "cpu_cores": [[1783290000, 0.12], [1783290360, 0.31]],
    "memory_bytes": [[1783290000, 812646400], [1783290360, 1265789952]],
    "disk_bytes": [[1783290000, 2147483648], [1783290360, 2147745792]]
  },
  "limits": { "cpu_cores": 2, "memory_bytes": 4294967296, "disk_bytes": 6442450944 },
  "hours": 24,
  "step_seconds": 360,
  "fetched_at": 1783293600
}
```

## Reading the numbers

* **Memory near its limit**: an agent that keeps climbing toward `limits.memory_bytes` will eventually be killed and restarted (that shows up in [logs](https://www.agent37.com/docs/agents-api/logs.md) as a rising `restart_count` and a `"critical"` memory verdict). [Resize](https://www.agent37.com/docs/agents-api/instances/resize.md) before it gets there.
* **CPU pinned at the limit**: sustained `cpu_cores` at `limits.cpu_cores` means the agent is throttled and everything it does is slower. Resize, or give it less concurrent work.
* **Disk trending up**: disk is the one series that never resets on restart. A steady climb is usually accumulated artifacts or caches; clean up over [exec](https://www.agent37.com/docs/agents-api/exec.md), or resize for more disk.

The same charts live in the dashboard on the instance's **Metrics** tab.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.