monitor.burn-rate
How fast an SLO's error budget is burning: the error rate as a multiple of the rate the SLO allows, in thousandths.
1.0.0 · published 2026-10-03 by charlie · Anterra
Pinned by 17 tests, run in TypeScript, Python and Rust.
What it does
How fast a service is spending its error budget: the error rate in a window divided by the error rate its SLO allows, as thousandths (`1000` = 1x).
burn = (bad / total) / ((10000 - target) / 10000)
For example
burnRate(99.9%, 1,000,000, 1,000)→ 1,000 0.1% errors against a 99.9% SLO is a burn rate of exactly 1xburnRate(99.9%, 10,000, 144)→ 14,400 1.44% errors against 99.9% is the workbook's 14.4x fast-burn page thresholdburnRate(99.9%, 1,000, 6)→ 6,000 0.6% errors against 99.9% is the workbook's 6x page threshold
The function
The same function in TypeScript, Python and Rust, pinned by the same tests. Pick your language; the choice follows you around the registry.
export function burnRate(targetBasisPoints: number, totalEvents: number, badEvents: number): number
| targetBasisPoints | int | the SLO: 9990 = 99.9%; 1 to 9999 |
| totalEvents | int | requests (or seconds) in the window being measured |
| badEvents | int | the failed ones; at most totalEvents |
| returns | int | burn rate x 1000, half-up: 1000 spends the budget exactly over the SLO period, 14400 is 14.4x |
Your code names it in one line, in the file that uses it
import { burnRate } from "#fune/monitor.burn-rate@^1";
/**
* How fast an SLO's error budget is burning, in thousandths: the window's
* error rate divided by the error rate the SLO allows. 1000 spends exactly
* the budget over the SLO period; 14400 (14.4x) spends 2% of a 30-day budget
* in one hour.
*
* Exact BigInt arithmetic: bad x 10000 x 1000 passes 2^53 at under a billion
* bad events.
*/
export function burnRate(targetBasisPoints: number, totalEvents: number, badEvents: number): number {
if (!Number.isSafeInteger(targetBasisPoints) || targetBasisPoints < 1 || targetBasisPoints > 9999) {
throw new RangeError(`targetBasisPoints must be a whole number from 1 to 9999 (10000 leaves no error budget), received ${targetBasisPoints}`);
}
if (!Number.isSafeInteger(totalEvents) || totalEvents < 0) {
throw new RangeError(`totalEvents must be a whole number of at least 0, received ${totalEvents}`);
}
if (!Number.isSafeInteger(badEvents) || badEvents < 0) {
throw new RangeError(`badEvents must be a whole number of at least 0, received ${badEvents}`);
}
if (badEvents > totalEvents) throw new RangeError(`badEvents must not exceed totalEvents: ${badEvents} > ${totalEvents}`);
// An empty window has no error rate; 0 keeps an alert quiet rather than failing it.
if (totalEvents === 0) return 0;
const n = BigInt(badEvents) * 10000n * 1000n;
const d = BigInt(totalEvents) * BigInt(10000 - targetBasisPoints);
return Number((2n * n + d) / (2n * d));
}Install
fune build
With that line in your source, in a TypeScript project (language typescript in fune.project), fune build resolves it and nothing else, pins them in fune.lock, downloads only the TypeScript package of each, and builds the code above into your project’s .fune/build, one readable file per capability with a header linking back here. Or pin a range in fune.project and build in one step:
fune add monitor.burn-rate
The manifest, vectors and README with only the TypeScript implementation. Install it without the registry with fune add ./monitor.burn-rate-1.0.0-typescript.fune, or fetch it from a terminal with fune pull monitor.burn-rate@1.0.0:typescript.
The whole function, every language, is one file too: monitor.burn-rate-1.0.0.fune, 10,928 bytes, sha256 46c18382d46a5017709173ffb79dffb5064f4708ea3cbc5a92acd65d672b4ccc. It installs into a project of any language.
Customise it in your app
The seams this capability offers. Put a marker directly above a function of your own and fune build wires it into the built code; the package on the registry is not changed, the built file’s header lists it under CUSTOMISED, and fune hooks lists every hook in the project. How hooks work.
before — your function gets the arguments and returns them, changed or not, or throws to refuse the call.
// fune: before monitor.burn-rate
after — your function gets the result and the arguments, and returns the final result.
// fune: after monitor.burn-rate
replace — it requires no other capability, so there is no dependency to replace.
step — your function runs at a numbered point inside the function’s body, receives the in-scope values it names as parameters, and may return replacements. List the points with fune show monitor.burn-rate --steps.
// fune: step monitor.burn-rate after <n|label>
Tests
A version published now needs at least 8 tests for every function, and one that expects the error for each function that throws; the registry refuses it otherwise. fune verify --all runs each case in TypeScript, Python and Rust, and a project runs them again with fune verify. This page lists the cases; it does not run them. The exact JSON is vectors.json.
| Case | Arguments | Expected | |
|---|---|---|---|
| 0.1% errors against a 99.9% SLO is a burn rate of exactly 1x | 99.9%, 1,000,000, 1,000 | → | 1,000 |
| 1.44% errors against 99.9% is the workbook's 14.4x fast-burn page threshold | 99.9%, 10,000, 144 | → | 14,400 |
| 0.6% errors against 99.9% is the workbook's 6x page threshold | 99.9%, 1,000, 6 | → | 6,000 |
| an empty window burns nothing | 99.9%, 0, 0 | → | 0 |
| no errors burns nothing | 99.9%, 50,000, 0 | → | 0 |
| every request failing at 99.9% is 1000x | 99.9%, 50, 50 | → | 1,000,000 |
| 1.5% errors against a 99% SLO is 1.5x | 99%, 200, 3 | → | 1,500 |
| rounds half up: 2.5 thousandths becomes 3 | 90%, 4,000, 1 | → | 3 |
| one error in three requests at 99.9% rounds down: 333.333x | 99.9%, 3, 1 | → | 333,333 |
| two errors in three requests at 99.9% rounds up: 666.667x | 99.9%, 3, 2 | → | 666,667 |
Show the other 7 tests
| Case | Arguments | Expected | |
|---|---|---|---|
| the loosest target, 0.01%: everything failing is barely over 1x | 0.01%, 9,999, 9,999 | → | 1,000 |
| a trillion requests at 99.99%: products pass 2^53 and stay exact | 99.99%, 1,000,000,000,000, 1,234,567,891 | → | 12,346 |
| a 100% target has no budget to burn and is an error | 100%, 100, 1 | → | error: targetBasisPoints must be a whole number from 1 to 9999 (10000 leaves no error budget), received 10000 |
| a 0% target is an error | 0%, 100, 1 | → | error: targetBasisPoints must be a whole number from 1 to 9999 |
| negative total is an error | 99.9%, -5, 0 | → | error: totalEvents must be a whole number of at least 0, received -5 |
| more bad events than events is an error | 99.9%, 4, 5 | → | error: badEvents must not exceed totalEvents: 5 > 4 |
| a fractional count is an error | 99.9%, 10, 1.5 | → | error: badEvents must be a whole number of at least 0, received 1.5 |
More from the author
At 1x the budget lasts exactly the SLO period (30 days in the workbook); at 14.4x a 30-day budget is gone in 50 hours, and one hour at that rate spends 2% of it (14.4 x 1h / 720h). Budget spent in a window = burn x window / period.
Burn rate is what SLO alerts compare against a threshold: see `monitor.burn-rate-alert` for the workbook's multiwindow, multi-burn-rate rules. On its own it is the number for a dashboard ("burning at 3.2x").
## Decisions
- **Thousandths, half up.** 14.4x is `14400`. Integers keep the three languages identical. An alert that must not fire early on rounding should compare exactly, as `monitor.burn-rate-alert` does. - **An empty window is 0**, not an error: no traffic spends no budget, and a quiet night should not break the alerting. - **Exact arithmetic.** bad x 10000 x 1000 passes 2^53 below a billion bad events, so the division is exact (BigInt in TypeScript, i128 in Rust, Python's integers). The design pinned `math.round-div`; it is not used, because its integers stop at 2^53. - **It works on seconds too**: total = window seconds, bad = down seconds.
## Errors
- `targetBasisPoints must be a whole number from 1 to 9999 (10000 leaves no error budget), received X` - `totalEvents must be a whole number of at least 0, received X` - `badEvents must be a whole number of at least 0, received X` - `badEvents must not exceed totalEvents: B > T`
## Sources
Google SRE Workbook, chapter 5 "Alerting on SLOs", section "Alert on Burn Rate" (https://sre.google/workbook/alerting-on-slos/): burn rate is how fast, relative to the SLO, the service consumes the error budget; 1 consumes all of it in the 30-day window; Table 5-8 uses 14.4, 6 and 1.
Files
| Path | Bytes |
|---|---|
| README.md | 1,926 |
| impl/python.py | 1,396 |
| impl/rust.rs | 2,087 |
| impl/typescript.ts | 1,445 |
| vectors.json | 2,093 |