Which backtest for which question
Lapilli answers one question: whether an alert rule earns its page, judged against what really went wrong. People ask it at different times, and each time wants a different run. This page says which.
Every command below needs a history (--prometheus URL, or a cloud’s
managed Prometheus) and what went wrong (--incidents FILE, or
--impact for windows a signal of user impact finds); they are left out to
keep the lines short. The check-replay command needs no incidents: it
refuses both.
Each week: do the rules earn their pages?
lapilli verdict --rules rules/ --since 7d
Read each rule’s stones: white when a firing caught an incident, black when
nothing was wrong. A noisy rule is marked, with a longer for that would
quiet it while keeping what it caught; an incident nothing caught lists the
rules that nearly did. Run it from cron or the chart’s CronJob
(Every week), or keep judging every hour with
lapilli serve (serve.md).
Before a change merges: what does it do?
lapilli verdict --compare rules-main/ --rules rules-branch/ --since 30d --fail-missed
Read the rules that differ, their firings before and after, and the
incidents caught differently. --fail-missed fails the job when the change
loses an incident; --expect FILE holds the rules to budgets and
incidents they must catch; --changed-only replays only the rules that
differ. A recording rule the change makes is written into the alerts that
read it, on both sides. In CI it is a pull request comment
(Pull request backtests, compare.md).
How sure is it?
lapilli verdict --rules rules/ --incidents incidents.yaml --since 28d --intervals
A precision of 60% may be 3 firings of 5 or 300 of 500. --intervals
gives each precision the range it could be in, with 95% confidence:
60% (23–88%), wide for a rule that fired a few times
(verdict.md). Beside a
backtest on a proposal’s page, lapilli serve shows the track record of
backtests made before, and says the range itself when the version proposed
had under ten firings judged, and on a rule’s page when fewer than ten of
its firings could be (design/howsure.md). The API and
MCP give it as precision_interval, and a pull request’s backtest through
serve takes intervals for it (INTERVALS=1 in the recipes).
Does the change do the same each week?
lapilli verdict --compare rules-main/ --rules rules-branch/ --since 28d --by-week
A month adds up to one number, so one loud week can carry it. --by-week
cuts the comparison by week: in how many weeks black stones are fewer
after, and the weeks an incident is lost. A change that helps three weeks
and hurts the fourth shows it. In lapilli serve, the same cut is on a
proposal’s page, folded under its backtest; MCP’s compare takes
by_week, and a pull request’s backtest through serve by_week
(BY_WEEK=1 in the recipes).
A new rule: how often would it have paged?
lapilli verdict --rules new-rule.yaml --since 90d
A rule nobody has run yet is replayed as if it had been: how often it
would have fired, what it would have caught, how many firings came at
night. A quarter gives it the incidents a week doesn’t have. To hold it to
that from then on, --draft-expectations FILE writes what it did as
expectations, for --expect to hold it to.
After an incident: would an alert have caught it?
lapilli verdict --rules rules/ --incident INC-1042
lapilli verdict --compare rules/ --rules rules-fixed/ --incident INC-1042
--incident replays the hours around one incident written down in
--incidents and shows it alone: which rules caught it and how long after
it started, which fired only once it was over, which nearly caught it
(a shorter for, a nearer number). With --compare, whether the fix a
retro proposes catches it, and how much sooner.
lapilli serve answers this one on the incident’s page, “Backtest it with
the rules in effect now”: would the rules in effect now catch it, and
sooner or later than they did then (serve.md). An agent asks
it with the incident tool, with or without a change to one rule
(mcp.md).
Which number, which for?
lapilli verdict --rules rules/ --since 28d --sweep HighErrorRate
--sweep replays one rule with round numbers around its own and with
fors from none to an hour, asking the history once (or once for each set of
fors whose look-backs fall on different steps). Each pair shows its
black stones, the incidents it caught and how soon. The rows shown are
those no other beats, chosen on the first three weeks; each says whether it
holds on the last week, kept apart. It picks nothing: a row worth trying
goes into a pull request, backtested with --compare.
lapilli serve answers it on the rule’s page, in the Number and for tab, for
the rule’s team’s editors, with “Propose this” on the rows that differ from the
rule as it is (serve.md); an agent asks it with
MCP’s sweep (mcp.md).
For a pull request that moves a number or a for, add --sweep-changed to the
comparison (SWEEP=true in the recipes, the action’s sweep, sweep in a
request to lapilli serve): for each rule the change tunes, the same table
around the change, with the rule before and the change marked, in the comment
beside it (compare.md).
Metrics that arrive late
lapilli verdict --rules rules/ --late 3m
A cloud’s own metrics, and some exporters’, arrive minutes after their
time. A replay reads the history as it is now, complete; --late reads it
as an evaluation would have, so a rule isn’t credited with catching what
its metrics hadn’t brought yet. PATTERN=DUR sets it per rule.
Pages at night
lapilli verdict --rules rules/ --work-hours mon-fri@09:00-18:00 --sleep-hours 23:00-07:00
The firings that caught nothing are counted by when they came, those that
woke people first. A team on call in turns says so with --shifts, or
--on-call with its schedules (how-it-judges.md).
Rules that changed during the period
lapilli verdict --rules rules-old/ --rules rules-new@2026-11-20T10:00:00Z --since 30d
Each firing is judged by the rules as they stood when it came.
--rules-history DIR takes the versions from a directory, which
recipes/versions/git.sh writes from git. lapilli serve records each
version itself.
Rules kept elsewhere
- Grafana’s:
--grafana URLreads them where they run; those whose queries can’t be replayed are judged from Grafana’s own history. - Loki’s:
--loki-rules, replayed against Loki (loki.md). - What a Prometheus already fired:
--alerts, no replay. - A cloud’s own alarms:
--alarms, or their history with--firings(cloud-alarms.md).
Is the replay right?
lapilli verdict --rules rules/ --check-replay
The replay set beside what really fired, rule by rule, from the ALERTS
series: a rule replayed far from it says why
(check-replay.md).
What it won’t answer
These are left out on purpose, to keep to the one question:
- “What if traffic doubled?” A backtest replays the history kept; made-up
series belong in a promtool scenario (
--promtoolwith--expect). - “What should the number be?” worked out for you.
--sweepmeasures each number; it doesn’t pick one, and Lapilli has no model of its own to pick with. - A rule changed without a person: a change goes through a pull request,
or a proposal a person approves in
lapilli serve. - Anything but alert rules: a dashboard, an SLO report, a query on its own.
- Stage against production: run it twice, with each
--prometheus.