← All Exercises

Spend an Error Budget Without Guessing

intermediatejavascript~25min

Background

Error budgets convert an SLO into an operational allowance. Teams that skip the arithmetic argue about whether the service is "fine" instead of acting on a number.

Problem

From total requests, failed requests and an SLO target, compute the allowed failure count, how much of the budget is consumed, what remains, and the daily allowance.

Input

JSON object: { totalRequests, failedRequests, sloPercent, windowDays }

Output

JSON object: { allowedFailures, consumedPercent, remaining, exhausted, dailyBudget }

Sample tests

Sample 1

Input: {"totalRequests":100000,"failedRequests":120,"sloPercent":99.9,"windowDays":30}
Expected: {"allowedFailures":100,"consumedPercent":120,"remaining":-20,"exhausted":true,"dailyBudget":3.3}

Sample 2

Input: {"totalRequests":100000,"failedRequests":40,"sloPercent":99.9,"windowDays":30}
Expected: {"allowedFailures":100,"consumedPercent":40,"remaining":60,"exhausted":false,"dailyBudget":3.3}

Your solution

Learning objective

Translate an SLO into an error budget and decide when to freeze releases.