Emre Şahin

Insinööripäiväkirja

Error Budgets as a Gate

Treating error budgets as an engineering control rather than a dashboard: burn rates, a budget gate for experiments, policy-gated remediation and forecasting.

Emre Şahin ·

Most teams I have worked with have an error budget somewhere. It is usually a Grafana panel. It turns red sometimes. People look at it in the weekly review, nod, and carry on.

An error budget that only informs is a nice chart. An error budget that changes what the system is allowed to do is a control. In FaultMesh I wanted the second kind, and this post is about what that looks like in the design.

A quick recap

An SLO says how reliable a service should be, for example 99.9% availability over 30 days. The error budget is the remaining 0.1%: the amount of unreliability you are allowed to spend. Every incident, every bad deploy and every chaos experiment that hurts users spends some of it.

FaultMesh tracks four SLI types per service: availability, p99 latency, error rate and throughput. Each SLO definition carries its own PromQL query, target and window.

Burn rate is the number that matters

Remaining budget tells you where you are. Burn rate tells you where you are going. A burn rate of 1 means you will use exactly your whole budget over the window. A burn rate of 10 means you will run out in a tenth of the time.

The scoring plane computes burn over 1-hour, 6-hour and 24-hour windows. The idea is the standard multi-window approach: the short window catches fast burns quickly, the long windows stop you from overreacting to a single bad five minutes.

Honest status: the first version computes these as consumed budget relative to the total for each window, which is coarse. Proper per-window rates derived from the SLI series, with paired short and long windows for alerting, are the next refinement. The interface does not change; the calculation behind it does.

The gate

Here is the control. Before a chaos experiment runs, the BudgetGate checks the target service's remaining budget. If less than 20% is left, the experiment is blocked.

public BudgetGateResult Evaluate(ErrorBudget budget)
{
    var allowed = budget.RemainingPercent >= _thresholdPercent; // default 20%
    return new BudgetGateResult(
        allowed,
        budget.RemainingPercent,
        _thresholdPercent,
        allowed ? null
                : 
quot;Error budget remaining ({budget.RemainingPercent:F1}%) is below threshold ({_thresholdPercent:F1}%)."); }

It is deliberately small. The gate is a pure function of the budget and a threshold. It does not query anything, it has no side effects, and it returns a reason a human can read. That makes it easy to test and easy to explain in an audit.

Why gate chaos experiments specifically? Because a chaos experiment is voluntary risk. If a service has already spent most of its budget on real incidents this month, the last thing it needs is someone deliberately adding more. The error budget is the shared agreement between product and reliability about how much risk is acceptable. The gate turns that agreement into something the system enforces, instead of something people remember.

The threshold is a trade-off. Gate too early and teams never get to run experiments on the services that most need them. Gate too late and the experiment that would have taught you something becomes the incident that blows the SLO. Twenty percent is a default, not a law; it is configurable because the right value depends on how a team uses its budget.

There is a tension here that I don't want to hide. The services burning the most budget are often exactly the ones that would benefit most from chaos testing. The gate says "not now", not "never". The answer is to run experiments when the budget recovers, in staging, or with a smaller blast radius, not to remove the gate.

Remediation is gated too

The same principle applies on the other side of the loop. When an anomaly is detected, remediation can act automatically: restart pods, scale an HPA, roll back a deployment, toggle a circuit breaker, shift traffic, drain a node. There are 18 executors in total, and several of them are destructive if pointed at the wrong thing.

So every remediation passes through a policy decision first. The policy engine is either OPA, for teams that already manage policy as code, or a built-in evaluator for teams that don't. It sees who or what triggered the action, the target, the environment and the action type, and returns allow or deny.

package faultmesh.remediation

default allow := false

allow if {
    input.action.type == "PodRestart"
    input.environment != "production"
}

allow if {
    input.action.type == "PodRestart"
    input.environment == "production"
    input.approval.granted
}

On top of policy:

  • Dry-run. A remediation plan can be evaluated without executing, showing what would run, in what order, and what policy said.
  • Dependency-aware sequencing. Actions are ordered by the service dependency graph, so you don't restart a consumer before the database it depends on is back.
  • Rollback planning. Each plan carries how to undo it, worked out before execution, not improvised during an incident.
  • Audit trail. Every decision, allowed or denied, is recorded with its context.

Approval gates for high-risk actions were still being finished in August 2026. The design keeps the approval step as a policy input, not a special code path, so adding approvers does not mean changing the executors.

Forecasting: from "where we are" to "when we run out"

A gate based on remaining budget reacts to the present. Teams also want to know: at this rate, when do we run out?

The scoring plane fits a small ML.NET SDCA regression on the history of burn rates and projects forward hour by hour, up to seven days by default, to estimate when cumulative burn crosses the remaining budget. It returns a predicted exhaustion time and a confidence value taken from the fit's R², clamped to between 0 and 1.

I want to be precise about what this is. It is a linear trend on a noisy signal. It is useful for "this service will run out by Thursday if nothing changes", and useless for predicting incidents. The confidence value is there so the panel can show a weak forecast as weak. With fewer than two data points, it does not guess; it says there is not enough history.

Why not something fancier? Because a forecast that drives decisions has to be explainable, and because the most important input, what the team does next, is not in the data anyway.

Why this is architecture, not tooling

Each of these pieces is small. A pure function for the gate. A policy call before every action. A regression on a single series. The architectural point is where they sit.

The budget gate sits in front of experiment execution, so no path can start an experiment without passing it. Policy sits in front of every executor, so no remediation can bypass it. Both return reasons, both are recorded, both can be explained to someone who was not in the room.

That is the difference between a dashboard and a control. A dashboard depends on someone looking at it. A control works when nobody is looking.

FaultMesh is a personal product under active development. More at faultmesh.com.