SLIs, SLOs and error budgets
Turn 'is checkout reliable enough?' into two ratios, a target and a budget you can spend, and record them in Prometheus so every alert and dashboard agrees
Checkout's SLO is 99.9% of requests succeed over 30 days. Traffic is a steady 5 requests per second. A bad deploy fails 20% of checkouts for 10 minutes, then is rolled back. How much of the 30-day error budget did it spend?
A service level indicator (SLI) is a number that says how well the service is doing for its users right now. A service level objective (SLO) is a target for that number over a window of time. The error budget is the gap between the target and perfection. This chapter defines all three for the demo app’s checkout, writes them as Prometheus recording rules in prometheus/rules/slo.yml, and spends some of the budget on purpose. The next chapter alerts on the rate at which the budget burns, and reads every series this chapter records.
SLI, SLO and SLA
The Google SRE book separates three words that are often used as one.
- An SLI is a carefully defined quantitative measure of some aspect of the service: the fraction of checkouts that succeed, the fraction that complete within 500 ms.
- An SLO is a target value for an SLI over a window: 99.9% of checkouts succeed, measured over a rolling 30 days.
- An SLA is an agreement with a customer that attaches consequences, usually service credits, to missing an objective. The SRE book’s test: ask what happens if the objective is missed. If nothing explicit happens, it is an SLO.
Two practical rules follow. The SLA target is looser than the internal SLO, so you find out you are in trouble before the contract does. And most services have no SLA at all and still need SLOs, because the SLO is the tool engineers use to decide what to work on. When someone says “we violated the SLA”, they almost always mean a missed SLO; a real SLA violation involves lawyers.
An SLI is a ratio of good events to valid events
The SRE Workbook recommends one shape for every SLI: the number of good events divided by the number of valid events, expressed as a percentage. Zero means nothing works; 100% means nothing is broken. That shape has three properties that a raw metric does not.
First, it is comparable across services and over time. “0.3% of checkouts failed” means the same thing at 5 requests per second and at 5,000. “14 errors per minute” does not.
Second, it adds up. Good events and valid events are both counters. You can sum them across instances, across regions and across hours, and divide once at the end. Percentiles do none of this: the p99 of two hosts is not the average of their p99s, which the histograms chapter proved in its lab.
Third, it gives you a budget for free. If the SLO is 99.9%, the budget is 0.1% of valid events. Over a window with a known number of events, that is a number of failures you are allowed.
The definition has two halves and both need care. Valid decides what counts at all: health checks and /metrics scrapes are not user traffic, and a request rejected because the client sent garbage arguably did not fail. Good decides what success means: a 200 that took 30 s is not good for a person waiting at a checkout button.
Where you measure it
The same SLI gives different numbers depending on where you count.
| Where | Sees | Misses |
|---|---|---|
In the service (its own /metrics) |
every request it handles, with route and status | requests that never reached it: a crashed process, a full listen queue, a broken load balancer |
| At the edge (gateway or load balancer) | everything the service missed, plus time spent queueing | failures between user and edge: DNS, TLS, CDN, the client’s network |
| In the client (RUM) | what the user saw | little, but the data is noisy, sampled and late |
| Synthetic probes | the full path, including DNS and TLS | partial faults, because a probe is a handful of requests |
Measure as close to the user as you can while keeping the data clean. For the demo app that is the gateway: it is the edge, it sees every checkout, and it reports http_requests_total and http_request_duration_seconds with job="gateway" and route="/checkout". The failure mode that the gateway cannot report, its own death, belongs to the synthetic probes chapter, which exists because a ratio of two counters has no data when the process exporting them is gone.
The SLIs for checkout
Availability. A valid event is any GET /checkout at the gateway. A bad event is one that returns a 5xx. When payments fails, orders returns 502 and so does the gateway, so FAULT_ERROR_RATE=0.2 makes almost exactly 20% of checkouts bad. A 4xx counts as good: the request was handled correctly and the client was wrong. The load generator never sends invalid arguments, so in the lab that choice changes nothing; in production it matters, and you write it down.
sum(rate(http_requests_total{job="gateway",route="/checkout",status=~"5.."}[5m]))
/
sum(rate(http_requests_total{job="gateway",route="/checkout"}[5m]))
That is the error ratio, one minus the SLI. Alerting works on the error ratio because the budget is expressed in errors.
Latency. A good event is a checkout that completes in 500 ms or less. The gateway’s histogram has a bucket bound at exactly 0.5 s, so the number of good requests is a counter Prometheus already has: http_request_duration_seconds_bucket with le="0.5". No interpolation, no percentile.
1 - (
sum(rate(http_request_duration_seconds_bucket{job="gateway",route="/checkout",le="0.5"}[5m]))
/
sum(rate(http_request_duration_seconds_count{job="gateway",route="/checkout"}[5m]))
)
Two details matter. The threshold must be a bucket bound; if the SLO said 400 ms, this histogram could not measure it exactly, and you would add a bound before you write the SLO, not after. And the le value must match the exposed label exactly. Prometheus 3 normalises le values on ingestion to a float representation, so a bound of 1 s is stored as le="1.0", and a rule that asks for le="1" returns nothing at all. The lab’s break step makes that happen.
This latency SLI counts failed requests too, and a failure that returns in 20 ms counts as fast. That is a deliberate choice: availability already punishes it, and counting it twice would double-spend one incident. Some teams count only successful requests in the latency SLI. Either is defensible if it is written down.
Two SLIs is the right number for one user journey. Teams that start with ten per service end up with dashboards nobody reads and budgets nobody defends.
Choosing the target
The SRE book is direct about 100%: it is the wrong target for almost everything. Users cannot tell 99.999% from 100% through their own Wi-Fi, mobile network and laptop, each of which fails far more often than that. And each extra nine costs much more engineering than the one before it, in redundancy, slower releases and on-call load.
| SLO | Error budget | Over 30 days, as full outage |
|---|---|---|
| 99% | 1% | 7.2 hours |
| 99.5% | 0.5% | 3.6 hours |
| 99.9% | 0.1% | 43.2 minutes |
| 99.95% | 0.05% | 21.6 minutes |
| 99.99% | 0.01% | 4.32 minutes |
Read the last row carefully. At 99.99%, one bad deploy that takes six minutes to roll back spends the month. Your SLO can be no better than the product of the SLOs of the things you call in series unless you add retries or fallbacks, so a checkout that calls a payment provider with a 99.9% SLA cannot promise 99.99% without a second provider.
Set the first target from history. Look at what the SLI has actually been over the last four weeks, and set the SLO at or a little below it, so it is achievable today and gets tighter as the service improves. A target nobody can meet trains everyone to ignore it.
For the demo app this chapter uses 99.9% availability and 99% of checkouts within 500 ms. The latency target is looser because the tail includes payment calls that the team does not control.
The window
An SLO needs a window. A rolling window (the last 30 days, recomputed continuously) matches what users remember: an outage on the 31st of the month is not forgiven on the 1st. A calendar window (this month, this quarter) matches business planning and SLA reporting. The SRE Workbook recommends a rolling window of a whole number of weeks, four weeks being its general-purpose choice, so every window holds the same number of weekends. This course uses 30 days because it is what most SLA contracts and most tooling default to; 28 days changes nothing in the method.
The error budget
The error budget is 1 − SLO of the valid events in the window. For checkout at 5 requests per second:
- 30 days × 86,400 s × 5 = 12,960,000 checkouts.
- 0.1% of that is 12,960 failed checkouts allowed.
- At 20% errors, which is
FAULT_ERROR_RATE=0.2, that is one failure per second: the whole budget is gone in 3.6 hours. - At 100% errors, it is gone in 43.2 minutes.
The budget is in events, not minutes, which is why the Predict above came out at 4.6% and not 0.02%. Ten minutes of 20% errors cost the same as two minutes of total outage.
What the budget is for
The budget makes reliability a resource that both sides of the Friday argument can see. While there is budget left, the team ships: a risky release that might spend 5% is fine. When the budget is gone, reliability work takes priority until the SLI recovers. This is written down in advance as an error budget policy, so it is not renegotiated during an incident. The SRE Workbook’s example policy says: if the service has exceeded its budget over the preceding four weeks, halt all changes and releases other than P0 issues or security fixes until it is back within its SLO; and if a single incident consumes more than 20% of the budget over four weeks, the team holds a postmortem with at least one P0 action item.
The policy is signed by the people who would otherwise argue: the product owner, the engineering lead, and whoever is on call. Without the policy an SLO is a number on a dashboard. With it, the number changes what happens on Friday.
Budget also runs the other way. A service that never spends any of its budget is either over-engineered or under-released. Some teams schedule planned downtime or chaos experiments to spend unused budget, which finds the dependencies that silently assumed 100%.
Recording the SLIs in Prometheus
Every alert, dashboard and report about an SLO evaluates the same few ratios over several windows. Writing that PromQL in each place guarantees they drift apart. A recording rule evaluates an expression on a schedule and stores the result as a new series, so everyone reads the same number and the expensive range query runs once.
The file this chapter’s lab writes, prometheus/rules/slo.yml, records three families of series:
| Series | Labels | Meaning |
|---|---|---|
slo:objective:ratio |
slo |
the target, 0.999 or 0.99 |
slo:error_budget:ratio |
slo |
one minus the target |
slo:sli_error:ratio_rate5m … ratio_rate30d |
slo |
the error ratio over 5m, 30m, 1h, 2h, 6h, 1d, 3d and 30d |
slo:error_budget_remaining:ratio |
slo |
the fraction of the 30-day budget left; negative when overspent |
The names follow Prometheus’s recording rule convention, level:metric:operations: the level is the aggregation (here the SLO itself), the metric is what is measured, and the operations are what was applied, newest first. Every series carries exactly one label, slo, with the value checkout-availability or checkout-latency. That single join label is what lets the next chapter write one set of burn-rate alerts for both SLOs, reading each threshold from slo:error_budget:ratio instead of hard-coding 0.001.
The windows are not arbitrary. 5m, 30m, 1h, 2h, 6h, 1d and 3d are the long and short windows of the SRE Workbook’s burn-rate alerts. 30d is the SLO window itself.
Three traps sit in these rules.
No errors is no data. prometheus_client creates a labelled series the first time it is incremented. Until checkout has failed once, there is no status="502" series, the numerator is an empty vector, and dividing an empty vector by anything is empty. The SLI of a perfectly healthy service would be blank. The rule adds or vector(0) to the numerator so a healthy service reads 0. The denominator gets no such fallback on purpose: no traffic should mean no SLI, not a perfect one.
Ratios of ratios lie. The 30-day error ratio is not the average of thirty daily ratios, because a day with ten times the traffic counts ten times as much. Prometheus’s own guidance: aggregate the numerator and the denominator first, divide last. Every rule in slo.yml sums both rates before dividing.
Long windows are expensive and need retention. rate(...[30d]) reads every sample of every matching series for 30 days at each evaluation. The rules for 1d, 3d and 30d live in a separate group that evaluates once a minute instead of every 5 seconds, which is plenty for numbers that move that slowly. And the 30-day ratio is only a 30-day ratio if Prometheus keeps 30 days: the lab stack runs with --storage.tsdb.retention.time=2d, so in the lab it is a ratio over whatever data exists. Because both rates are divided by the same window length, the ratio is still correct for that data; it is the window that is short. In production, SLO windows need retention of at least the window, or a long-term store.
Where SLOs go wrong
- The SLI measures the server, not the user. A service that counts only the requests it handled reports 100% while its load balancer returns 503s to everyone. Measure at the edge, and add probes for the cases the edge cannot see.
- The target is aspirational. 99.99% on a service that achieved 99.8% last month means the budget is always negative, the policy is always in force, and so it is ignored.
- Nobody owns the policy. An SLO with no agreed consequence is a metric. The test is whether a release has ever been delayed because of it.
- Too many SLOs. One or two per user journey. Every additional SLO is another budget someone has to defend.
- Low traffic. At ten checkouts an hour, one failure is a 10% error ratio. The ratio is honest and useless for alerting; the next chapter covers what to do about it.
- Set and forgotten. Review SLOs every quarter against what users complained about. If users were unhappy while the SLO was green, the SLI is measuring the wrong thing.
You will write prometheus/rules/slo.yml with both SLIs over eight windows, unit-test it with promtool, load it into the running Prometheus, compute the 30-day budget, and burn some of it with FAULT_ERROR_RATE. The next chapter reads this file, so keep it when you finish.
1. Start the stack and define a query helper.
cd labs/observability
docker compose --profile telemetry up -d --build
q() { curl -sG localhost:9090/api/v1/query --data-urlencode "query=$1" | jq -r '.data.result[] | "\(.metric.slo // "-")\t\(.value[1])"'; }
sleep 60
q 'sum(rate(http_requests_total{job="gateway",route="/checkout"}[1m]))'- and a number close to 5: the load generator sends 5 checkouts per second, and every SLI below is a fraction of these. The - is the empty slo label, which the recorded series in step 3 will fill. Keep this terminal: q is used in every step.2. Look at the raw SLIs before recording them.
q '(sum(rate(http_requests_total{job="gateway",route="/checkout",status=~"5.."}[5m])) or vector(0)) / sum(rate(http_requests_total{job="gateway",route="/checkout"}[5m]))'
q 'sum(rate(http_requests_total{job="gateway",route="/checkout",status=~"5.."}[5m])) / sum(rate(http_requests_total{job="gateway",route="/checkout"}[5m]))'
curl -s localhost:8080/metrics | grep 'http_request_duration_seconds_bucket{.*/checkout.*le="0.5"'- 0. The second, the same ratio without or vector(0), prints nothing: no checkout has failed, so no 5xx series exists and the ratio has no data. A dashboard built on it would be blank on a healthy service. The curl line shows the 0.5 s bucket as the gateway exposes it, with le="0.5" and a count close to the total, since nearly every checkout is fast.3. Write prometheus/rules/slo.yml. The two rules per window differ only in the window, so generate them. Run this from labs/observability:
cat > prometheus/rules/slo.yml <<'EOF'
# SLOs for GET /checkout at the gateway (observability/slis-slos-error-budgets).
# Every series carries one label, slo, so alerts can join on it.
groups:
- name: slo-checkout-objectives
rules:
- record: slo:objective:ratio
expr: vector(0.999)
labels: { slo: checkout-availability }
- record: slo:objective:ratio
expr: vector(0.99)
labels: { slo: checkout-latency }
- record: slo:error_budget:ratio
expr: 1 - slo:objective:ratio
EOF
sli() { # sli <window>: the two error-ratio rules for one window
cat <<EOF
- record: slo:sli_error:ratio_rate$1
labels: { slo: checkout-availability }
expr: |
(sum(rate(http_requests_total{job="gateway",route="/checkout",status=~"5.."}[$1])) or vector(0))
/
sum(rate(http_requests_total{job="gateway",route="/checkout"}[$1]))
- record: slo:sli_error:ratio_rate$1
labels: { slo: checkout-latency }
expr: |
1 - (
sum(rate(http_request_duration_seconds_bucket{job="gateway",route="/checkout",le="0.5"}[$1]))
/
sum(rate(http_request_duration_seconds_count{job="gateway",route="/checkout"}[$1]))
)
EOF
}
{
printf ' - name: slo-checkout-sli\n rules:\n'
for w in 5m 30m 1h 2h 6h; do sli $w; done
printf ' - name: slo-checkout-sli-long\n interval: 1m\n rules:\n'
for w in 1d 3d 30d; do sli $w; done
cat <<'EOF'
- record: slo:error_budget_remaining:ratio
expr: 1 - slo:sli_error:ratio_rate30d / on(slo) slo:error_budget:ratio
EOF
} >> prometheus/rules/slo.yml
docker compose exec prometheus promtool check rules /etc/prometheus/rules/slo.ymlSUCCESS: 20 rules found: three objective rules, ten short-window SLI rules, six long-window ones and the budget-remaining rule. Open the file and read one window’s pair; it is the two expressions from the body of this chapter with a slo label added. The prometheus/ directory is mounted into the container at /etc/prometheus, which is why promtool inside the container sees the file you wrote on the host.4. Unit-test the rules before loading them. A recording rule that returns no data fails silently forever, so test the two traps. Create prometheus/tests/slo-test.yml (a directory outside rules/, so Prometheus does not try to load it as rules):
mkdir -p prometheus/tests
cat > prometheus/tests/slo-test.yml <<'EOF'
# promtool test rules prometheus/tests/slo-test.yml
rule_files:
- ../rules/slo.yml
evaluation_interval: 1m
tests:
# 1 h of clean traffic at 5 req/s: no 5xx series exists yet.
- name: no errors yet is zero, not no data
interval: 1m
input_series:
- series: 'http_requests_total{job="gateway",route="/checkout",method="GET",status="200"}'
values: '0+300x60'
promql_expr_test:
- expr: slo:sli_error:ratio_rate5m{slo="checkout-availability"}
eval_time: 60m
exp_samples:
- labels: 'slo:sli_error:ratio_rate5m{slo="checkout-availability"}'
value: 0
- expr: slo:error_budget_remaining:ratio{slo="checkout-availability"}
eval_time: 60m
exp_samples:
- labels: 'slo:error_budget_remaining:ratio{slo="checkout-availability"}'
value: 1
# 1% of checkouts fail and 5% take longer than 0.5 s, from the start.
- name: ratios and budget
interval: 1m
input_series:
- series: 'http_requests_total{job="gateway",route="/checkout",method="GET",status="200"}'
values: '0+297x60'
- series: 'http_requests_total{job="gateway",route="/checkout",method="GET",status="502"}'
values: '0+3x60'
- series: 'http_request_duration_seconds_bucket{job="gateway",route="/checkout",method="GET",status="200",le="0.5"}'
values: '0+285x60'
- series: 'http_request_duration_seconds_count{job="gateway",route="/checkout",method="GET",status="200"}'
values: '0+300x60'
promql_expr_test:
- expr: round(slo:sli_error:ratio_rate1h * 1000) # per mille
eval_time: 60m
exp_samples:
- labels: '{slo="checkout-availability"}'
value: 10
- labels: '{slo="checkout-latency"}'
value: 50
- expr: round(slo:error_budget_remaining:ratio * 100) # per cent
eval_time: 60m
exp_samples:
- labels: '{slo="checkout-availability"}'
value: -900
- labels: '{slo="checkout-latency"}'
value: -400
EOF
docker compose exec prometheus promtool test rules /etc/prometheus/tests/slo-test.ymlSUCCESS. values: '0+300x60' is promtool’s expanding notation: start at 0 and add 300 per step for 60 steps, a counter at 5 requests per second sampled once a minute. The first test proves a healthy service reads 0 errors and a full budget. The second proves the ratios (1% and 5%) and shows that a budget can go negative: 1% errors against a 0.1% budget is ten times the budget, so 1 − 10 = −9, printed as −900%. The round(... * 1000) is there because the recorded ratios carry floating-point noise in the 15th digit and promtool compares exactly. Now delete or vector(0) from the 5m availability rule in slo.yml, rerun the test, and watch the first test fail with got: nil. Put it back.5. Load the rules and read the recorded series.
curl -s -X POST localhost:9090/-/reload
sleep 60
curl -s localhost:9090/api/v1/rules | jq -r '.data.groups[] | select(.name | startswith("slo-checkout")) | .rules[].health' | sort | uniq -c
q 'slo:error_budget:ratio'
q 'slo:sli_error:ratio_rate5m'
q 'slo:error_budget_remaining:ratio'20 ok. Then checkout-availability 0.001 and checkout-latency 0.01 (printed with floating-point noise, such as 0.0010000000000000009); both error ratios at or near 0; and budget remaining at or near 1 for both. If the latency ratio is a little above 0, a few checkouts took over 500 ms while the containers warmed up. A rule reports unknown until its first evaluation, and the long-window group evaluates once a minute, which is why you waited before reading anything.6. Compute the 30-day budget in events.
q 'sum(rate(http_requests_total{job="gateway",route="/checkout"}[2m])) * 30 * 86400'
q 'sum(rate(http_requests_total{job="gateway",route="/checkout"}[2m])) * 30 * 86400 * 0.001'12960000 checkouts in 30 days at the current rate, and about 12960 failures allowed. That is the number every incident is charged against. The window is 2 minutes because rate() divides by the window length: on a stack that has been up for five minutes, a [10m] window holds half that much data and would report half the real rate. If your load generator runs slower than 5 per second because the laptop is busy, both numbers shrink in proportion and the budget in minutes of full outage stays 43.2.7. Burn the availability budget. Make 20% of charges fail for ten minutes:
FAULT_ERROR_RATE=0.2 docker compose --profile telemetry up -d payments
sleep 300; q 'slo:sli_error:ratio_rate5m'
sleep 300
q 'sum(increase(http_requests_total{job="gateway",route="/checkout",status=~"5.."}[11m]))'
q 'sum(increase(http_requests_total{job="gateway",route="/checkout",status=~"5.."}[11m])) / (sum(rate(http_requests_total{job="gateway",route="/checkout"}[10m])) * 30 * 86400 * 0.001)'
docker compose --profile telemetry up -d payments0.2 and latency stays near 0: failed checkouts return fast, and this SLI design does not charge them twice. After ten minutes the gateway has served about 600 failed checkouts, plus a handful from the seconds when payments was being recreated, and the last query reads about 0.046: this incident spent 4.6% of the month’s budget, the Predict’s answer. The final command recreates payments without the variable, so the fault returns to its default of 0.8. Read the budget Prometheus thinks you have.
q 'slo:sli_error:ratio_rate30d'
q 'slo:error_budget_remaining:ratio'-40 and -100 on a stack that has been up for less than an hour. The 30-day window covers only the data Prometheus has, so ten bad minutes out of thirty look like a month at 2% errors. This is the retention trap from the body: the formula is right and the window is short. In production you would see 0.954 here after this incident, and the number would be worth putting in front of the product manager.9. Burn the latency budget.
FAULT_SLOW_PAYMENTS_PCT=20 docker compose --profile telemetry up -d payments
sleep 300
q 'slo:sli_error:ratio_rate5m'
q 'histogram_quantile(0.99, sum by (le) (rate(http_request_duration_seconds_bucket{job="gateway",route="/checkout"}[5m])))'
docker compose --profile telemetry up -d payments0.2 and availability is back near 0 (or falling, as the errors from step 7 leave the 5-minute window). The p99 is somewhere between 2.5 and 3 s. The p99 says “slow” but cannot tell you how much of the budget went; the ratio can: 20% slow against a 1% budget is a burn rate of 20, which empties a 30-day budget in a day and a half. That multiplier is the subject of the next chapter.le="0.5" with le="1", regenerate the file, run promtool check rules (it passes) and reload. q 'slo:sli_error:ratio_rate5m' now prints only the availability line: the latency SLI has vanished. The gateway exposes that bucket as le="1.0", and Prometheus 3 normalises le to that float form on ingestion as well, so le="1" matches no series, the numerator is empty, and every alert built on the SLI is silently disarmed while promtool check reports success. Only a unit test with realistic input series catches it. Put le="0.5" back and regenerate before the next chapter.You are setting the first availability SLO for checkout. The last four weeks measured 99.94% at the gateway. The payment provider's SLA is 99.9% monthly, and checkout has no fallback provider. The VP of product wants 99.99% because 'checkout is revenue'. Which target do you propose?
- BOOK Site Reliability Engineering, chapter 4: Service Level Objectives Chris Jones, John Wilkes, Niall Murphy, Cody Smith, 2016
Where the vocabulary comes from: the SLI, SLO and SLA distinction, why 100% is the wrong target, and the advice on choosing targets with product owners. Read it before arguing about any of them. Read: the whole chapter; it is short.
- BOOK The Site Reliability Workbook, chapter 2: Implementing SLOs Steven Thurgood, David Ferguson, Alex Hidalgo, Betsy Beyer, 2018
The practical companion to the SRE book chapter: the good-over-valid ratio, the SLI menu for request-driven services, where to measure, rolling versus calendar windows, and a worked example with real queries. Skip the pipeline-system examples if you only run request services. Read: 'What to Measure: Using SLIs', 'Choosing an Appropriate Time Window' and 'Getting Stakeholder Agreement'.
- BOOK The Site Reliability Workbook, Appendix: Example Error Budget Policy
A complete error budget policy with goals, non-goals, the release freeze rule, the 20% postmortem rule and escalation. Copy its structure for your own; it is the document that turns an SLO into a decision. Read: the whole policy; about two pages.
- BOOK Implementing Service Level Objectives Alex Hidalgo, 2020
The book-length treatment by one of the Workbook chapter's authors. Strongest on the human side the Google books skim: getting agreement, choosing targets from history, and what to do when the budget runs out. Part II's statistics chapters are optional. Read: Part I, on SLIs, choosing targets and using error budgets.
- DOC Prometheus: recording rules best practices
The level:metric:operations naming convention used by every rule in this chapter, and the rule about aggregating numerator and denominator before dividing. Short, and prevents the ratio-of-ratios mistake.
- DOC Prometheus: unit testing for rules
The reference for promtool's test file: input series notation, promql_expr_test and alert_rule_test. You use the first here and the second in the next chapter.
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.