Multi-Window Burn Rate Alert
Problem Statement
Implement a multi-window burn-rate alert: fire only when the error budget is being consumed too fast over both a long and a short window (to catch fast burns while avoiding flapping).
Background
Burn rate = observed_error_rate / (1 - slo) — how many times faster than sustainable the budget is being spent. A page fires when the burn rate exceeds threshold over the long window AND over the short window simultaneously. Given error rates for each window, decide whether to alert.
Your Task
def burn_alert(slo, long_err_rate, short_err_rate, threshold):
Return True if both windows' burn rates exceed threshold, else False.
Input Format
- slo (float), long_err_rate, short_err_rate (float), threshold (float).
Output Format
- A boolean.
Sample
print(burn_alert(0.99, 0.15, 0.20, 10.0))
Output:
True
Example
print(burn_alert(0.99, 0.15, 0.20, 10.0))
True
- Calculate the sustainable error budget rate by subtracting the SLO from 1, representing the maximum acceptable error fraction: .
- Determine the long-window burn rate by dividing the observed long error rate by the budget rate to see how many times faster the budget is being consumed: .
- Determine the short-window burn rate by dividing the observed short error rate by the budget rate: .
- Evaluate the alert condition, which requires both burn rates to strictly exceed the threshold of : is true and is true.
- The final output is True
Constraints
- burn = err_rate / (1 - slo).
- Alert only if BOTH long and short burn > threshold.
- Return a bool.