How do you compute "error budget remaining" in PromQL?
AdvancedConceptError Budgets & Burn-Rate Alerting
Answer
1 - (
slo:sli_error:ratio_rate30d{slo="checkout-availability"}
/ (1 - 0.999)
)
1 means the full budget is left, 0 means exhausted, negative means you are over budget. Display it as a percentage stat panel with thresholds at 50%, 25% and 0%. Note that rate(...[30d]) is expensive; compute it in a recording rule in its own group with a longer interval (for example 5m) so it does not run on every evaluation cycle.
More on Error Budgets & Burn-Rate Alerting
What is an error budget and how do you calculate it?BeginnerWhat is an error-budget policy?BeginnerWhat happens when the error budget is exhausted? Is it a punishment?IntermediateWhat should you do if the error budget is never spent?IntermediateWhat is burn rate?IntermediateHow much budget does an alert at burn rate B over window W consume?Advanced