*Cloud › Services*

# Get service metrics

```http
GET https://devapi.dispralabs.com/v1/cloud/services/:svc/metrics
```

Returns CPU, memory and network out for the service and each replica over a range, from one-minute windows, with the limits in force.

Needs a key with `read` access or more.

- **Authentication:** Secret key (send it as `Authorization: Bearer <key>`)

## Parameters

- `svc` (string, required): The service's id. Example: `svc_01jdk3n2f4g6h8j0k2l4z6x8ca`
- `range` (string, optional): 1h, 3h, 24h, 7d or 30d (default 24h). Example: `24h`

## Returns

- **200** [The metrics object](https://docs.dispralabs.com/objects/the-metrics-object.md): The metrics.

## Errors

| Status | Code | When |
|---|---|---|
| 400 | [invalid_range](https://docs.dispralabs.com/errors.md#invalid_range) | range is 1h, 3h, 24h, 7d or 30d. |
| 404 | [not_found](https://docs.dispralabs.com/errors.md#not_found) | No such object in the key's project (or environment). |

## Request samples

### Dispra Cloud CLI

```bash
dcloud api GET /v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/metrics?range=24h
```

### cURL

```bash
curl "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/metrics?range=24h" \
  -H "Authorization: Bearer dsp_live_YOUR_KEY"
```

### Node

```javascript
const res = await fetch("https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/metrics?range=24h", {
  method: "GET",
  headers: { Authorization: "Bearer dsp_live_YOUR_KEY" },
});
console.log(await res.json());
```

### Python

```python
import requests
res = requests.request("GET", "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/metrics", headers={"Authorization": "Bearer dsp_live_YOUR_KEY"}, params={"range": "24h"})
print(res.json())
```

### Go

```go
req, _ := http.NewRequest("GET", "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/metrics?range=24h", nil)
req.Header.Set("Authorization", "Bearer dsp_live_YOUR_KEY")
res, _ := http.DefaultClient.Do(req)
```

## Responses

### 200

```json
{
  "data": {
    "range": "24h",
    "step_s": 300,
    "series": {"cpu_millis":[[1764324900,412]],"memory_mb":[[1764324900,618]]},
    "replicas": [{"replica":"r1","cpu_millis":[[1764324900,205]]}],
    "limits": {"cpu_millis":1000,"memory_mb":1024}
  }
}
```

### 400 invalid_range

```json
{
  "error": {
    "code": "invalid_range",
    "message": "range is 1h, 3h, 24h, 7d or 30d.",
    "request_id": "req_7f3a9c21d84be056"
  }
}
```

### 404 not_found

```json
{
  "error": {
    "code": "not_found",
    "message": "No such object in the key's project (or environment).",
    "request_id": "req_7f3a9c21d84be056"
  }
}
```
