Skip to content

SLO Management

SLOs are managed through internal/handlers/slo.go which exposes a RESTful API.

Key Concepts

FieldTypeDescription
targetfloat64SLO target percentage (0–100), e.g. 99.9 for 99.9%
time_windowstringEvaluation window: 1h, 24h, 7d, 30d, 90d
metric_typestringOne of availability, latency, throughput
metric_querystringPrometheus PromQL query for calculation

CRUD Operations

List SLOs

http
GET /slos?page=1&page_size=10

Returns paginated results ordered by created_at DESC. Only active SLOs (active = true) are returned.

Get SLO

http
GET /slos/{id}

Create SLO

http
POST /slos
Content-Type: application/json

{
  "name": "API Availability",
  "target": 99.9,
  "time_window": "30d",
  "metric_type": "availability",
  "metric_query": "sum(rate(http_requests_total{status=~\"2..\"}[5m])) / sum(rate(http_requests_total[5m]))",
  "team_id": 1
}

Update SLO

http
PATCH /slos/{id}
Content-Type: application/json

{ "target": 99.99, "time_window": "7d" }

Uses dynamic query building — only provided fields are updated.

Delete SLO

http
DELETE /slos/{id}

Performs a soft-delete by setting active = false.

SLO Status Indicators

Status is determined by determineSLOStatus() in internal/prometheus/calculator.go:

StatusCondition
healthycurrent / target >= 0.99 (availability) or current <= target × 1.2 (latency)
warning0.95 <= current / target < 0.99 (availability) or current <= target × 1.5 (latency)
criticalcurrent / target < 0.95 (availability) or current > target × 1.5 (latency)

For availability-based SLOs, higher is better. For latency, lower is better.

Error Budget & Burn Rate

  • Error Budget: calculated as ((target - current) / target) × 100. Budget is consumed when actual performance falls below target.
  • Burn Rate: inferred from error budget consumption over the time window. Automatic alerts fire when consumption exceeds configured thresholds.