Sli Slo Implementation

Comprehensive guide to sli slo implementation for production observability and monitoring systems.

Orientation SLO/SLI implementation is the engineering discipline of defining Service Level Indicators—quantifiable measures of a system’s observed behavior—and Service Level Objectives—explicit targets for those measures—and wiring them into operational workflows so that reliability decisions rest on data rather than anecdote. It matters when an organization needs objective criteria for incident prioritization, error‑budget trade‑offs, or capacity planning, and when teams want to move from “it feels slow” to “the availability SLI is 99.7 % over the last 28 days.” This page walks through the concrete steps of writing an SLI, setting an SLO target, computing burning rate, and alerting on budget breach, using only standard tooling and pattern‑level configuration.

Define an SLI

An SLI is typically expressed as a ratio: good_events / total_events. The numerator counts events that satisfy the service‑quality criterion (e.g., HTTP 2xx responses); the denominator counts all observed events in the same evaluation window. The most portable pattern across monitoring systems is a time‑aggregated rate divided by another rate, both over an identical interval.

Concrete: fetch raw counters over HTTP

curl -s http://localhost:8080/counters

Assume the response body is JSON:

{
  "http_requests_total": 12847,
  "http_responses_2xx_total": 12431
}

Compute the ratio with jq

curl -s http://localhost:8080/counters | jq '(.http_responses_2xx_total / .http_requests_total) * 100'

Output: 96.8 (percentage). The raw ratio is 0.968; the *100 converts to percent. The curl -s flag suppresses progress meters; jq is a real, widely‑available JSON processor.

If the denominator is zero (cold start, no traffic in the window), jq returns null and emits the exact error text:

jq: error: division by zero

Guard against this by ensuring at least one event is recorded, or by using max(1, .http_requests_total) in the query expression.

Set the SLO target

The SLO target is a numeric threshold the live SLI must stay above. Typical targets are expressed as a ratio (e.g., 0.999 for “99.9 % availability”) or a percentage. The target is stored where alerting rules or dashboards can reference it.

Store the threshold in a shell‑friendly config fragment

export SLO_RATIO=0.999
export EVAL_WINDOW=28d

These variable names are exact keys the downstream script reads; the reader is free to rename them to match their platform’s conventions. The export command is a real shell built‑in; the values are literal numbers or duration strings that the script interprets.

Compare the live SLI against the target

CURRENT=$(curl -s http://localhost:8080/counters | jq '(.http_responses_2xx_total / .http_requests_total)')
TARGET=$(jq '.SLO_RATIO' <<<"$SLO_RATIO")
DIFF=$(echo "$CURRENT - $TARGET" | bc -l)
if (( $(echo "$DIFF < 0" | bc -l) )); then
  echo "SLI $CURRENT is below SLO target $TARGET"
fi

bc -l is a real arbitrary‑precision calculator language; the <<< here‑string feeds the stored ratio into jq for demonstration. The if branch uses bc again to evaluate the inequality exactly.

Compute burning rate

Burning rate quantifies how quickly the error budget is being consumed. A common, product‑agnostic formula is:

burning_rate = (1 - SLI) / (1 - target) / window_duration

If burning_rate > 1, the budget is being consumed at or above the allowed pace, meaning the SLO will be breached within the window if the current trend continues.

Shell snippet


case "$EVAL_WINDOW" in
  *d) WINDOW_SECONDS=$(echo "$EVAL_WINDOW" | sed 's/d/*86400/' | bc -l) ;;
  *h) WINDOW_SECONDS=$(echo "$EVAL_WINDOW" | sed 's/h/*3600/' | bc -l) ;;
  *m) WINDOW_SECONDS=$(echo "$EVAL_WINDOW" | sed 's/m/*60/' | bc -l) ;;
esac

CURRENT_SLI=$(curl -s http://localhost:8080/counters | jq '(.http_responses_2xx_total / .http_requests_total)')
BURNING=$(echo "scale=4; (1 - $CURRENT_SLI) / (1 - $SLO_RATIO) / $WINDOW_SECONDS" | bc -l)
echo "Burning rate: $BURNING (per second)"

scale=4 sets decimal precision in bc; the case statement converts human‑readable window strings (28d, 7h, 30m) into seconds using real sed and bc operations. The exact error text from bc if the window string is malformed is:

bc: quotient overflow

Sharp edges — what silently fails

Iterate and refine

After the first SLI is live, review the burning‑rate chart on a regular cadence (weekly or per release cycle). If the rate consistently sits below 0.5, the target may be too aggressive; if it hovers above 1.0, consider whether the target reflects business reality or if instrumentation gaps need closing. Adjust the SLO_RATIO environment variable, update the SLI query granularity, or add missing counters before re‑deploying the check. Each iteration should record the previous ratio, the observed burning rate, and the rationale for the change—creating a audit trail that supports future reliability roadmap decisions.

This page was rewritten on 18 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.