Skip to main content

slo-kit

Stop hand-rolling SLO alerts. Define SLOs as code and get correct multi-window burn-rate Prometheus alerts for free.

CI PyPI Python License

slo-kit turns raw Prometheus / OpenTelemetry metrics into:

  • SLO definitions as code — SLI query + target + rolling window, in YAML or Python.
  • Live error-budget & burn-rate tracking — consumed, remaining, and time-to-exhaustion.
  • Correct multi-window / multi-burn-rate Prometheus alert rules — per the Google SRE workbook.

SLO math (error budgets, multi-window multi-burn-rate alerting) is subtle and commonly implemented incorrectly. slo-kit packages it correctly and reusably, so you define reliability targets and get paged on budget burn without hand-rolling brittle PromQL.

Install

pip install slo-kit
# or
docker run --rm ghcr.io/slo-kit/slo-kit --help

Quickstart (< 5 minutes)

1. Define an SLO (checkout_slo.yaml):

apiVersion: slo-kit/v1
name: checkout-availability
service: checkout
description: Checkout API availability
objective: 0.999          # three nines
window: 30d               # rolling 30-day window
sli:
  # {window} is substituted per alert/budget window
  good_query: 'sum(rate(http_requests_total{job="checkout",code!~"5.."}[{window}]))'
  total_query: 'sum(rate(http_requests_total{job="checkout"}[{window}]))'
labels:
  team: payments

2. Validate it:

slo-kit validate checkout_slo.yaml

3. Check live budget & burn rate:

slo-kit status checkout_slo.yaml --source http://localhost:9090

4. Generate correct multi-window burn-rate alerts:

slo-kit gen-alerts checkout_slo.yaml > checkout_rules.yaml

5. Gate deploys on remaining budget (CI):

slo-kit gate checkout_slo.yaml --source http://localhost:9090 --min-budget 0.1
# exits non-zero when < 10% budget remains

From Python

from slo_kit import load_spec, evaluate_status, generate_rules_yaml
from slo_kit import PrometheusSource

slo = load_spec("checkout_slo.yaml")
source = PrometheusSource("http://localhost:9090")

status = evaluate_status(slo, source)
print(f"budget remaining: {status.budget_remaining_pct:.1%}")
print(f"1h burn rate:     {status.burn_rate('1h'):.2f}x")

print(generate_rules_yaml(slo))   # Prometheus alerting rules

Why multi-window multi-burn-rate?

Alerting on a single window forces a bad trade-off: short windows page fast but cry wolf; long windows are stable but slow to fire and slow to reset. The SRE workbook fix is to require two windows at once — a long window that measures how much budget is burning, and a short window (≈1/12 of it) that confirms the burn is still happening right now:

severity long short burn rate budget burned before firing (30d)
page 1h 5m 14.4× 2%
page 6h 30m 5%
ticket 24h 2h 10%

slo-kit implements this in alerts/multiwindow.py and emits the equivalent Prometheus rules from alerts/prometheus_rules.py — validated against an explicit truth table and golden files.

Core concepts

  • SLIgood_events / total_events from a metric query.
  • SLO target — e.g. 0.999 over a rolling window (e.g. 30d).
  • Error budget — allowed failures = (1 - target) × total; track consumed, remaining, remaining %, and time-to-exhaustion.
  • Burn rateobserved_error_rate / (1 - target); a burn rate of 1 exactly exhausts the budget over the window, >1 is too fast.
  • Multi-window multi-burn-rate alerts — fast + slow burn condition sets to balance fast detection against low false positives.

See the documentation for concepts, the full API, and examples.

Development

pip install -e ".[dev]"
ruff check . && ruff format --check .
mypy src/slo_kit
pytest --cov=slo_kit --cov-report=term-missing

License

Apache-2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slokit_sre-1.0.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

slokit_sre-1.0.0-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

Details for the file slokit_sre-1.0.0.tar.gz.

File metadata

  • Download URL: slokit_sre-1.0.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for slokit_sre-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d1a253caf5ff5fd49583fe6efcdb7d64f1f9e611dc233b29d0d9d00b13aab8be
MD5 c038d8b217c319508c2006ec4be37065
BLAKE2b-256 f45d77a9d9654ad2efade9475ec3c6d7b3287e9adbce00d771657665f72c174e

See more details on using hashes here.

Provenance

The following attestation bundles were made for slokit_sre-1.0.0.tar.gz:

Publisher: release.yml on akaashhazarika/slo-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slokit_sre-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: slokit_sre-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for slokit_sre-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b000df3f4690b93f8f297a92ab420ba068c485038f2d06151305646dbe0541eb
MD5 6775416bfe342575a880907f83633917
BLAKE2b-256 0d04b1be74f8cb9d06bbfed8c5f351877e921a6459f913cf300d83268f7d90a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for slokit_sre-1.0.0-py3-none-any.whl:

Publisher: release.yml on akaashhazarika/slo-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page