Calculate burn against a defined service objective
An SLO defines which user events count as good and the acceptable fraction over a window. Error budget is the permitted bad fraction, while burn rate compares the observed bad fraction to that allowance. A raw failure count has no meaning without its denominator and window.
This exercise calculates a window summary, including a defined result for no traffic. A complete alerting policy would combine short and long windows and avoid treating a single tiny sample as decisive. The same computation can drive a release gate, but selecting the objective is a product and operational decision rather than an automatic metric choice.
good,total=990,1000
objective=.999
bad_rate=1-good/total
print(round(bad_rate/(1-objective),3))Review the design
Burn is normalized to the objective, so one means consuming budget at the planned rate. The event definition and time window must accompany the number before it is used in an incident or release decision.
Your task
Implement slo_window(good,total,objective). Require integers 0<=good<=total, total>=0 and 0<objective<1. Return dict availability and burn; for zero traffic return None for both.
The explanation opens here once every check passes.