slo-kit
Stop hand-rolling SLO alerts. Define SLOs as code and get correct multi-window burn-rate Prometheus alerts for free.
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 | 6× | 5% |
| ticket | 24h | 2h | 3× | 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
- SLI —
good_events / total_eventsfrom a metric query. - SLO target — e.g.
0.999over a rolling window (e.g.30d). - Error budget — allowed failures
= (1 - target) × total; track consumed, remaining, remaining %, and time-to-exhaustion. - Burn rate —
observed_error_rate / (1 - target); a burn rate of1exactly exhausts the budget over the window,>1is 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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1a253caf5ff5fd49583fe6efcdb7d64f1f9e611dc233b29d0d9d00b13aab8be
|
|
| MD5 |
c038d8b217c319508c2006ec4be37065
|
|
| BLAKE2b-256 |
f45d77a9d9654ad2efade9475ec3c6d7b3287e9adbce00d771657665f72c174e
|
Provenance
The following attestation bundles were made for slokit_sre-1.0.0.tar.gz:
Publisher:
release.yml on akaashhazarika/slo-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
slokit_sre-1.0.0.tar.gz -
Subject digest:
d1a253caf5ff5fd49583fe6efcdb7d64f1f9e611dc233b29d0d9d00b13aab8be - Sigstore transparency entry: 2230769082
- Sigstore integration time:
-
Permalink:
akaashhazarika/slo-kit@7ca64d8ba5c1d13e52422731119fd13e691832be -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/akaashhazarika
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ca64d8ba5c1d13e52422731119fd13e691832be -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b000df3f4690b93f8f297a92ab420ba068c485038f2d06151305646dbe0541eb
|
|
| MD5 |
6775416bfe342575a880907f83633917
|
|
| BLAKE2b-256 |
0d04b1be74f8cb9d06bbfed8c5f351877e921a6459f913cf300d83268f7d90a6
|
Provenance
The following attestation bundles were made for slokit_sre-1.0.0-py3-none-any.whl:
Publisher:
release.yml on akaashhazarika/slo-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
slokit_sre-1.0.0-py3-none-any.whl -
Subject digest:
b000df3f4690b93f8f297a92ab420ba068c485038f2d06151305646dbe0541eb - Sigstore transparency entry: 2230769162
- Sigstore integration time:
-
Permalink:
akaashhazarika/slo-kit@7ca64d8ba5c1d13e52422731119fd13e691832be -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/akaashhazarika
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ca64d8ba5c1d13e52422731119fd13e691832be -
Trigger Event:
push
-
Statement type: