SLI Authoring
A Service Level Indicator (SLI) is a lightweight, periodic health check that produces a 0–1 score. Most SLIs use binary checks (0 = failing, 1 = passing) aggregated as a mean, but SLIs can push any float in the 0–1 range — for example, a latency-based SLI might return 0.85 to indicate partial health. When the score drops below a configured alert threshold, the associated runbook is triggered automatically.
When to build an SLI
| Bundle type | Examples | SLI approach |
|---|---|---|
| Health / monitoring | *-healthcheck, *-health, *-monitor | In-repo sli.robot with a dedicated SLI template |
| Operational / triage | *-ops, *-triage, *-restart, *-remediate | Cron-scheduler SLI that periodically triggers the runbook |
| Chaos / one-off | *-chaos-*, manual remediation | Typically no SLI (runbook is on-demand only) |
If the bundle answers “is this resource healthy right now?”, it needs an in-repo SLI. If it answers “perform this action”, use the cron-scheduler pattern.
Design principles
- Lightweight — complete in under 30 seconds
- Frequent — runs every 30–600 seconds (
intervalSecondsin the template, typically 180 for namespace-level, 300–600 for resource-level) - Read-only — never modify resources; use
access:read-onlytags - Idempotent — safe to run continuously without side effects
- Binary or fractional — most checks produce 0 (failing) or 1 (passing), aggregated as an arithmetic mean for the final score. SLIs can also push fractional values (e.g. 0.85) for partial-health signals like latency percentiles
- Configurable thresholds — use
RW.Core.Import User Variablewith sensible defaults so each deployment can tune sensitivity - Safe error handling — wrap JSON parsing in
TRY/EXCEPT; default to a reasonable value (typically 0 for strict, 1 for optional checks)
RW_LOOKBACK_WINDOW — the big gotcha
RW_LOOKBACK_WINDOW controls how far back time-windowed SLI signals look
(failed-build ratio, recent activity, etc.). It is not the same as the
deep investigation window used by runbooks.
| Context | Who sets it | Typical value | Purpose |
|---|---|---|---|
SLI (sli.robot) | Platform (from intervalSeconds) | ~scrape interval × 1.5 | Current-state gauge |
Runbook (runbook.robot) | configProvided + Import User Variable | 24h, 7d, 30d | Deep investigation after SLO breach |
Do not put RW_LOOKBACK_WINDOW in the SLI template configProvided. If
you hard-code 24h there, the SLI will treat failures as in-window for that
entire period and stay unhealthy long after recovery.
In sli.robot, import it as a platform variable with a fallback for local dev:
TRY ${RW_LOOKBACK_WINDOW}= RW.Core.Import Platform Variable RW_LOOKBACK_WINDOWEXCEPT ${RW_LOOKBACK_WINDOW}= Set Variable 2700END${RW_LOOKBACK_WINDOW}= RW.Core.Normalize Lookback Window ${RW_LOOKBACK_WINDOW} 2Set Suite Variable ${RW_LOOKBACK_WINDOW} ${RW_LOOKBACK_WINDOW}The ro dev runner simulates SLI context by unsetting RW_RUNREQUEST_ID
and exporting RW_LOOKBACK_WINDOW defaulting to intervalSeconds × 1.5
(override with RW_SLI_INTERVAL_SECONDS, default 1800 → 2700).
SLI template checklist
When authoring the *-sli.yaml template:
pathToRobot: codebundles/<bundle>/sli.robotintervalStrategy: intermezzointervalSeconds:aligned to desired scrape intervalconfigProvided:user variables only (org, namespace, thresholds) — noRW_LOOKBACK_WINDOWalertConfigwithpersona: eager-edgarandsessionTTLso SLO breach triggers the runbook