# Metrics API

Metrics. 2 operations under /api/v1. Errors are RFC 9457 problem+json with a stable `code` field. The complete schemas are in https://nebulactrl.com/api/v1/openapi.json.

## GET /servers/{serverId}/metrics

Host CPU, memory and disk over time

Authentication: session cookie or `Authorization: Bearer nct_…` token.

Parameters:
- `serverId` (path, string, required)
- `range` (query, enum: 5m | 10m | 30m | 1h | 6h | 12h | 24h | 7d | 30d): Time window; each response has at most 300 points

Response 200: OK (ServerMetricsOutputBody)
  - `points` (MetricPoint[] | null, required)
  - `retentionDays` (integer (int64), required): How many days of history this server keeps; longer ranges only show what is retained
  - `stepSeconds` (integer (int64), required): Bucket width of every point
Errors: 401 Unauthorized; 403 Forbidden; 404 Not Found; 422 Unprocessable Entity; 500 Internal Server Error

## GET /services/{serviceId}/metrics

CPU and memory of a service's container

At most 300 points of `stepSeconds` each. `range` is one of 5m, 10m, 30m, 1h (default), 6h, 12h, 24h, 7d, 30d; longer ranges read downsampled tiers and carry the per-bucket peaks `cpuMax`/`memMax`. Memory is usage minus inactive file cache. `retentionDays` is how long the service's server keeps history.

Authentication: session cookie or `Authorization: Bearer nct_…` token.

Parameters:
- `serviceId` (path, string, required)
- `range` (query, enum: 5m | 10m | 30m | 1h | 6h | 12h | 24h | 7d | 30d)

Response 200: OK (MetricsOutputBody)
  - `points` (ServiceMetricPoint[] | null, required)
  - `retentionDays` (integer (int64), required): Days of history kept on the service's server; longer ranges only show what is retained
  - `stepSeconds` (integer (int64), required): Bucket width of every point
Errors: 401 Unauthorized; 403 Forbidden; 404 Not Found; 422 Unprocessable Entity; 500 Internal Server Error
