← DocsRecipe

Recipe: Service SLO + error-budget writer

Ship a lightweight SLO tracker that writes error budgets into Meridian KV so your alerting pipeline can consume them in real time.

Ingredients

  • Meridian project with KV store enabled
  • Prometheus or Datadog metrics endpoint
  • SLI definition (latency p99, error rate, availability)
  • Target SLO percentage (e.g. 99.95%)

Steps

  1. Define your SLI query

    Write the exact PromQL or Datadog query that returns good events divided by total events over your compliance window.

  2. Create the writer function

    Deploy a cron-triggered edge function that fetches the SLI, computes the error budget remaining, and calls meridian.kv.set.

  3. Wire up alerting

    Point your alert manager at the KV key. Trigger when budget burn rate exceeds your threshold.

KV schema

{
  "slo:checkout-api": {
    "window": "30d",
    "target": 99.95,
    "budget_remaining_pct": 0.042,
    "burn_rate_1h": 2.1,
    "updated_at": "2026-01-17T14:02:00Z"
  }
}

Gotchas

  • Use atomic writes to avoid partial updates mid-read
  • Keep compliance window aligned with your SLO period
  • Cache the SLI query result for at least 60s to avoid rate limits

Need the full writer implementation? Grab the TypeScript starter from starters.