<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yair Stark</title>
    <description>The latest articles on DEV Community by Yair Stark (@yairst).</description>
    <link>https://dev.to/yairst</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1045940%2F1c4bc655-f97f-461c-8a21-a9df88e18c94.jpeg</url>
      <title>DEV Community: Yair Stark</title>
      <link>https://dev.to/yairst</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yairst"/>
    <language>en</language>
    <item>
      <title>Error Budget Is All You Need - Part 2</title>
      <dc:creator>Yair Stark</dc:creator>
      <pubDate>Sun, 22 Jun 2025 04:06:54 +0000</pubDate>
      <link>https://dev.to/yairst/error-budget-is-all-you-need-part-2-3inb</link>
      <guid>https://dev.to/yairst/error-budget-is-all-you-need-part-2-3inb</guid>
      <description>&lt;p&gt;In &lt;a href="https://dev.to/yairst/error-budget-is-all-you-need-part-1-46ag"&gt;part 1&lt;/a&gt; I proposed a simple modification to Google’s &lt;a href="https://sre.google/workbook/alerting-on-slos/#6-multiwindow-multi-burn-rate-alerts" rel="noopener noreferrer"&gt;&lt;em&gt;Multi-Window Multi-Burn Rate&lt;/em&gt; alerting setup&lt;/a&gt; and I showed how this modification addresses the cases of varying-traffic services and typical latency SLOs.&lt;/p&gt;

&lt;p&gt;While my proposed solution was simply to alert on the error budget instead of the error rate, &lt;strong&gt;in this part I will show how we can still alert on the error rate but do it correctly. More importantly, the novel error-rate-based alert I will develop will expose a dynamic time-dependent burn rate expression which in contrast to Google’s static one leads to built-in compatibility to varying-traffic services.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;A certain disadvantage in my proposed solution in &lt;a href="https://dev.to/yairst/error-budget-is-all-you-need-part-1-46ag"&gt;part 1&lt;/a&gt; is that the metric which it alert on is the error budget while the metrics we care for when implementing SRE are the SLIs (or the actual error rate) and the percentage of error budget consumption. Hence, alerting on the error budget might not be consistent with our SLO and percentage of error budget consumption dashboards.&lt;/p&gt;

&lt;p&gt;Again, the solution for this is quite easy. Eventually, the alert rule is just inequality between the actual number of bad requests in the alerting time window to some multiple of the error budget (defined by the percentage of error budget consumption that we want to alert on). If we divide this inequality by the total number of requests in the alerting time window we will get the desired inequality rule for an error-rate-based alert.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;wa&lt;/em&gt;&lt;/strong&gt; - Alert time window (for example 1h, 6 h, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;wslo&lt;/em&gt;&lt;/strong&gt; - SLO period (7 days, 28 days, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Na(t)&lt;/em&gt;&lt;/strong&gt; - Total number of events in the alert time window, &lt;em&gt;wa&lt;/em&gt; .&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Nb(t)&lt;/em&gt;&lt;/strong&gt; - Total number of bad events in the alert time window, &lt;em&gt;wa&lt;/em&gt; .&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Nslo(t)&lt;/em&gt;&lt;/strong&gt; - Total number of events in the SLO period, &lt;em&gt;wslo&lt;/em&gt; .&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;EB(t)&lt;/em&gt;&lt;/strong&gt; - Error budget. The allowable number of bad events for the SLO period, &lt;em&gt;wslo&lt;/em&gt; .&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;EBPt&lt;/em&gt;&lt;/strong&gt; - The percentage of error budget consumption used as a threshold for alerting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;SLO&lt;/em&gt;&lt;/strong&gt; - The SLO defined on the SLO period, &lt;em&gt;wslo&lt;/em&gt;. expressed as fraction (0.99, 0.999, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;ERslo&lt;/em&gt;&lt;/strong&gt; - The allowable error rate for the SLO window, &lt;em&gt;wslo&lt;/em&gt; : &lt;em&gt;1-SLO&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;ER(t)&lt;/em&gt;&lt;/strong&gt; - The actual error rate calculated on the alert time window, &lt;em&gt;wa&lt;/em&gt; :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxdyw1e4a2etwuf69kpw7.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxdyw1e4a2etwuf69kpw7.webp" alt="Error rate"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;BR&lt;/em&gt;&lt;/strong&gt; - The static burn rate as defined in &lt;a href="https://sre.google/workbook/alerting-on-slos/" rel="noopener noreferrer"&gt;chapter 5&lt;/a&gt; of Google’s SRE workbook:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpar6iv4n75bnka4pjthp.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpar6iv4n75bnka4pjthp.webp" alt="Burn rate"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;where &lt;em&gt;(t)&lt;/em&gt; denotes time-dependent variables.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Static Burn Rate Is Wrong?
&lt;/h2&gt;

&lt;p&gt;The starting point in Google’s solution is a percentage of error budget consumption that we want to alert on, given the alert time window. That means that the alerting rule we should originate from is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F77sl3dbkhzxkliytxw4i.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F77sl3dbkhzxkliytxw4i.webp" alt="alert on percentage of error budget consumption"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, since the natural choice is to alert on the error rate and in order to transform the defined percentage of error budget consumption to error rate threshold, Google used the aforementioned definition of burn rate to give the following alerting rule:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcyylajmvyp76wxs85oli.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcyylajmvyp76wxs85oli.webp" alt="alert on error rate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Substituting the error rate and burn rate terms with their aforementioned definitions into the above expression gives:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8xdd4fg6vdn1k7eqxzn.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8xdd4fg6vdn1k7eqxzn.webp" alt="alert on error rate expanded"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and by multiplying the above expression with &lt;em&gt;Na(t)&lt;/em&gt; / &lt;em&gt;EB(t)&lt;/em&gt; we get:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd26y159j9cexpwhr4eov.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd26y159j9cexpwhr4eov.webp" alt="alert on error rate expanded and multiplied by"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Comparing the right-side of this expression with the right-side of the percentage-of-error-budget alerting rule above leads to the following equation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ra4bh9zeaqokdbwef9k.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ra4bh9zeaqokdbwef9k.webp" alt="some expression equals 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;which we can develop to the following result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7sewei06jb6soxde3r85.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7sewei06jb6soxde3r85.webp" alt="condition when static burn rate holds"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and this is exactly the root cause for the incompatibility of Google’s alerting solution to varying-traffic services: &lt;strong&gt;The burn-rate-based alerting rule of Google holds only when the total number of events in the alerting time window is equal to the average number of events for this window along the SLO period.&lt;/strong&gt; In all other cases, reaching the burn-rate threshold doesn’t mean that we reach the percentage-of-error-budget threshold that we aim for in the first place…&lt;/p&gt;

&lt;h2&gt;
  
  
  Time-Dependent Burn Rate
&lt;/h2&gt;

&lt;p&gt;As mentioned above the remedy is to formulate the error-rate-based alert directly from the percentage-of-error-budget-based alert rule as follows. As we already saw, the alert rule on the percentage of error budget consumption is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm68eewc60bwdwhe3nn3q.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm68eewc60bwdwhe3nn3q.webp" alt="alert on percentage of error budget consumption"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Multiplying the above expression by &lt;em&gt;EB(t)&lt;/em&gt; / &lt;em&gt;Na(t)&lt;/em&gt; gives:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1i3m1f637e5w5205xyym.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1i3m1f637e5w5205xyym.webp" alt="alert on EBP multiplied by EB/Na"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The left side is by definition the error rate, &lt;em&gt;ER(t)&lt;/em&gt;, and the error budget term can be expressed as multiplication of the SLO error rate and the total number of events in the SLO period:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flydctjroly0l597ekxe1.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flydctjroly0l597ekxe1.webp" alt="alert on EBP multiplied by EB/Na and expanded"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and just by rearranging the terms on the right side, we get the desired alert rule:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1afuspu3cj3r1exmxs1f.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1afuspu3cj3r1exmxs1f.webp" alt="alert on EBP multiplied by EB/Na and expanded"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;where we can immediately notice the new time-dependent burn-rate term:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7x44drytp6mfas1ey9xm.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7x44drytp6mfas1ey9xm.webp" alt="dynamic burn rate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;where the constant ratio between the SLO period to the alerting time window has been replaced by the more favorable time-dependent ratio between the total number of events in the SLO period to the total number of events in the alerting time window.&lt;/p&gt;

&lt;p&gt;To illustrate the importance of using dynamic burn rate I used a web traffic dataset from Kaggle, “&lt;a href="https://www.kaggle.com/kleberbernardo/example-web-traffic-with-lstm" rel="noopener noreferrer"&gt;Example web traffic&lt;/a&gt;” with typical varying-traffic: low traffic at nights and high traffic during the day, and plot the traffic against the dynamic burn rate and the static one as a reference, as shown in the figure below:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;br&gt;
    &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F41mqtdm9r0es22utqr4w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F41mqtdm9r0es22utqr4w.png" alt="dynamic vs static burn rate"&gt;&lt;/a&gt;&lt;br&gt;Dynamic vs Static Burn Rates for 28-day SLO and threshold of 2% error budget consumption
    &lt;br&gt;
  &lt;/p&gt;

&lt;p&gt;As expected, the dynamic burn rate change significantly over time as a function of the number of requests (hits): It is high at low traffic hours so only a high error rate will cause the alert to fire and vice versa at high-traffic hours. This is exactly the desired behavior we seek to obtain fixed error budget consumption alerts. It can also be seen that the difference between the dynamic to the static burn rate can reach up to two orders of magnitude, which emphasizes how unsuitable the static threshold is to be used for alerting on a fixed percentage of error budget consumption.&lt;/p&gt;

&lt;p&gt;We can also extend this observation by extracting the “actual (wrong) error budget consumption threshold” which is obtained when the static burn rate is used:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg2uvnzf5ikzkl2mfp9v.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg2uvnzf5ikzkl2mfp9v.webp" alt="br_expressed_based_on_actual_wrong_ebp"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;where:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbwutu1zbylwaiuejrfju.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbwutu1zbylwaiuejrfju.webp" alt="wrong_ebp_expression"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;is this actual error budget consumption threshold. Notice again how this term is equal to the fixed error budget consumption target only when the ratio between the total events in the SLO period to the total events in the alerting time window is equal to the constant ratio between the SLO period to the alerting time window. If we plot it we will get:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc0exfetqimuq2grl0wai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc0exfetqimuq2grl0wai.png" alt="actual ebp plot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This figure also emphasizes the incompatibility of the static burn rate to varying-traffic services, where we eventually alert on different error budget consumptions each hour: in low-traffic hours on low ones, hence decreasing the precision, and in high-traffic hours on high ones, hence decreasing the recall. Moreover, the third pick demonstrates how in cases of an unusual increase in the traffic volume the miss becomes much more significant: In our case, the alert will fire only if we already consumed ~27% of the error budget…&lt;/p&gt;

&lt;h2&gt;
  
  
  3rd Option: Alert on Percentage of Error Budget
&lt;/h2&gt;

&lt;p&gt;So far we discussed error-budget-based (in &lt;a href="https://dev.to/yairst/error-budget-is-all-you-need-part-1-46ag"&gt;part 1&lt;/a&gt;) and error-rate-based alerting setups (in this part). Notice that those two setups have non-constant terms in the threshold expression: In the error-budget-based alert this is &lt;em&gt;Nslo(t)&lt;/em&gt; and in the error-rate-based alert these are &lt;em&gt;Nslo(t)&lt;/em&gt; and &lt;em&gt;Na(t)&lt;/em&gt; . For those who will argue that these kinds of dynamic thresholds can be confusing or misleading, there is a third option (or maybe this is the first natural option).&lt;/p&gt;

&lt;p&gt;Since both of the above setups derived from the fixed threshold on the percentage of error budget, why not alert directly on this percentage? Recall the alert rule on the percentage of error budget consumption is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F77sl3dbkhzxkliytxw4i.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F77sl3dbkhzxkliytxw4i.webp" alt="alert on percentage of error budget consumption"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From here we can immediately get the final alert expression as:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvgetgwypkqduz614bzzr.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvgetgwypkqduz614bzzr.webp" alt="alert_expr_based_on_ebp_final"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice that all three alerting options are equivalent: All of them will fire when we cross over the defined percentage of error budget threshold. In fact, the above 3rd one is obtained by dividing both sides of the 1st one, the error-budget alert expression, by &lt;em&gt;ERslo&lt;/em&gt; &lt;em&gt;x&lt;/em&gt; &lt;em&gt;Nslo(t)&lt;/em&gt; .&lt;/p&gt;

&lt;p&gt;The nice thing this alert expression reveals to us is that we actually don’t care about the total number of events in the alerting window. The only influential metrics are the total number of bad events in the alerting window and the total number of events in the SLO period. This is directly due to the definition of the percentage of error budget consumption as our starting point for the alert. Since this percentage is defined on the whole SLO period, the total number of events in the alert time window shouldn’t influence it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Computational Considerations
&lt;/h2&gt;

&lt;p&gt;Since all the three options of alerting on the error budget consumption require up-to-date measuring of the total number of events in the SLO period, it may be computationally heavy. However, since this metric changes slowly over time we don’t necessarily have to measure it as frequently as the other metrics. Instead, we can sample it once a day and it should be enough. To validate it I resampled the calculated rolling &lt;em&gt;Nslo(t)&lt;/em&gt; :&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F63qehj3nx6jzvo4rdl8j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F63qehj3nx6jzvo4rdl8j.png" alt="resampled_total_events_last_28_days"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and plot the approximated dynamic burn rate, which is calculated based on the resampled &lt;em&gt;Nslo(t)&lt;/em&gt; , vs. the true dynamic burn rate:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc05hw3o3n6mkuzfxnm5i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc05hw3o3n6mkuzfxnm5i.png" alt="approx_dynamic_burn_rate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see there is no significant difference between the true burn rate to the approximated one. Even when the difference between the actual &lt;em&gt;Nslo(t)&lt;/em&gt; to the resampled one is relatively large, as there is on 21/10/2017, its influence on the burn rate is negligible. We can validate this observation by calculating &lt;a href="https://arxiv.org/ftp/arxiv/papers/2105/2105.05249.pdf" rel="noopener noreferrer"&gt;the log of the accuracy ratio&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;np.log10(df_sample[‘dynamic burn rate’] / df_sample[‘aprox dynamic burn rate’]).mean()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which results in only 0.008.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In &lt;a href="https://dev.to/yairst/error-budget-is-all-you-need-part-1-46ag"&gt;part 1&lt;/a&gt; of this post, I introduced the incompatibility of Google’s &lt;em&gt;Multi-Window Multi-Burn Rate&lt;/em&gt; alerting setup to varying-traffic services and/ or relative low SLOs. As a proposed solution I presented the 1st of three alternatives to this setup which is to alert on the error budget.&lt;/p&gt;

&lt;p&gt;To strengthen the above argument, in this part, I showed mathematically why Google’s alerting setup can not fit the case of varying-traffic services. Additionally, I presented two more alternatives, equivalent to the first one, hence also compatible with the scenario of varying-traffic services. To summarize and by using the aforementioned notations, those 3 alternatives are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Error-Budget-Based Alert:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo6fazlp7vuuynpwswy5y.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo6fazlp7vuuynpwswy5y.webp" alt="error_budget_based_alert"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Error-Rate-Based Alert:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy0o1mw2nymtlrs2u4tqh.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy0o1mw2nymtlrs2u4tqh.webp" alt="alert_on_error_rate_with_dynamic_burn_rate_final"&gt;&lt;/a&gt;  &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Percentage-of-Error-Budget-Based Alert:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jnhmu6gpofa4hfkjwdi.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jnhmu6gpofa4hfkjwdi.webp" alt="alert_expr_based_on_ebp_final"&gt;&lt;/a&gt;  &lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;where it is easy to notice the equivalence that exists between the above expressions.&lt;/p&gt;

&lt;p&gt;I hope you will find this post, in its two parts, helpful for alerting on your SLOs.&lt;/p&gt;

</description>
      <category>sre</category>
      <category>slo</category>
      <category>errorbudget</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Error Budget Is All You Need - Part 1</title>
      <dc:creator>Yair Stark</dc:creator>
      <pubDate>Sun, 22 Jun 2025 04:03:33 +0000</pubDate>
      <link>https://dev.to/yairst/error-budget-is-all-you-need-part-1-46ag</link>
      <guid>https://dev.to/yairst/error-budget-is-all-you-need-part-1-46ag</guid>
      <description>&lt;p&gt;One of the great chapters of &lt;a href="https://sre.google/workbook/table-of-contents/" rel="noopener noreferrer"&gt;Google’s Site Reliability Engineering (SRE) second book&lt;/a&gt; is &lt;a href="https://sre.google/workbook/alerting-on-slos/" rel="noopener noreferrer"&gt;chapter 5 — Alerting on SLOs&lt;/a&gt; (Service Level Objectives). This chapter takes you on a comprehensive journey through several setups of alerts on SLOs, starting with the simplest non-optimized one and by iterating through several setups reach the ultimate one, which is optimized w.r.t to the main four alerting attributes: recall, precision, detection time and reset time.&lt;/p&gt;

&lt;p&gt;To summarize: For each SLO, the ultimate alerting setup, &lt;a href="https://sre.google/workbook/alerting-on-slos/#6-multiwindow-multi-burn-rate-alerts" rel="noopener noreferrer"&gt;&lt;em&gt;Multiwindow, Multi-Burn-Rate Alert&lt;/em&gt;&lt;/a&gt;, sets several thresholds based on different error budget consumptions: 2 %, 5 %, and 10 %, on relatively long windows of 1,6 and 72 hours respectively. This setup leads to both high recall and high precision while keeping the detection time relatively short. To minimize the reset time, the setup defines short windows (1/12 of the long ones) such the alert fires only if both the long window and the short one cross over the threshold.&lt;/p&gt;

&lt;p&gt;However, after exploring this solution on different Service Level Indicators (SLIs) and against some scenarios, it seems that it has some limitations. &lt;strong&gt;In this post, I will elaborate on those limitations and the reasons for their existence. To address them, I propose a simple but significant improvement to the above setup, which makes it generalize better, specifically for varying-traffic services and for low SLO scenarios.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Definitions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SLI&lt;/strong&gt; - Service Level Indicator. Expressed as the ratio between the number of good events to the total number of events in a given time window. For example, for an availability SLI of a web application, all the successful HTTP requests will be considered as good events.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxuv2vs9h8h0hsik3gs13.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxuv2vs9h8h0hsik3gs13.webp" title="taken from Google’s Site Reliability Engineering course in Coursera" alt="SLI definition"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SLO&lt;/strong&gt; -Service Level Objective. A target on the SLI. Notice that the above definition of SLI implies that we always want our SLIs to be as high as possible or not to pass pre-defined lower bound. The SLO is this lower bound. An SLO must have a time window on which the SLO is defined. Common choices are week, 28, or 30 days. For example, 99.9% 30-day availability SLO means that we want our availability SLI on &lt;strong&gt;any&lt;/strong&gt; 30-day window will not to fall below 99.9 %.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Actual Error Rate&lt;/strong&gt; (or simply “error rate”) - The complementary of the SLI, namely the ratio between the number of bad events to the total number of events.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SLO Error Rate&lt;/strong&gt; - The complementary of the SLO. Define an upper bound on the actual error rate. For example, the SLO error rate of 99.9 % SLO is 0.1 %.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Error Budget -&lt;/strong&gt; The number of allowable bad events in a given SLO time window. The error budget can be measured on a given time window to set a starter achievable SLO or to be calculated by multiplying the total number of events in an SLO time window by the SLO error rate, in the case of pre-defined SLO. Notice that the above definition of error budget is taken from &lt;a href="https://sre.google/workbook/alerting-on-slos/" rel="noopener noreferrer"&gt;chapter 5 — Alerting on SLOs&lt;/a&gt;, though in other sources (including Google’s ones) you may find the term “error budget” used as the above-defined SLO error rate or as allowable downtime minutes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Burn Rate&lt;/strong&gt; - How fast, relative to the SLO, the service consumes the error budget. The Figure below explains it well for 30-day SLO:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwc5j7st6jll568fuz1ym.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwc5j7st6jll568fuz1ym.webp" title="taken from Google's SRE workbook, chapter 5: Alerting on SLOs" alt="Burn Rate graph"&gt;&lt;/a&gt;&lt;br&gt;
we can see that with a burn rate of 2 we consume all the budget in 15 days, while with a burn rate of 1 only 50 % of the budget is consumed in this period.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Burn Rate Thresholds
&lt;/h2&gt;

&lt;p&gt;It is important to note that the percentage of error budget consumption is the starting point for each window defined in the discussed alerting setup, as this is the most intuitive measure to reason about: “notify me only if we pass 2% error budget consumption in 1 hour or 5 % error budget in 6 hours”. However, it is taken for granted in the chapter that the metric we are alerting on is not the actual percentage of error budget consumption but rather the error rate, hence some transformation is needed.&lt;/p&gt;

&lt;p&gt;Indeed, the implementation of the above alerting solution is done by transforming the different error budget consumptions (for each alerting window) into &lt;strong&gt;burn rates&lt;/strong&gt; by the following equation:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbb2312v15tioc0d8vch.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbb2312v15tioc0d8vch.webp" alt="burn rate equation"&gt;&lt;/a&gt;&lt;br&gt;
where ‘period’ is the period on which the SLO is defined (usually 28 or 30 days). Based on this transformation, the threshold of each window is defined as the multiplication of the SLO error rate by the burn rate calculated for this window.&lt;/p&gt;

&lt;p&gt;For example, consumption of 2 % of a 30-day error budget in only one hour is translated by the equation above to a burn rate of 14.4. Multiplying this burn rate by the SLO error rate gives the desired threshold: For 99.9 % SLO, we will get a threshold of 14.4 × 0.1 % = 1.44 %, meaning fire alert only if the error rate in the last hour is greater than 1.44 %.&lt;/p&gt;

&lt;p&gt;In the same manner, we get a burn rate of 6x for 5 % budget consumption in 6 hours window and a burn rate of 1x for 10% budget consumption in 3 days window.&lt;/p&gt;
&lt;h2&gt;
  
  
  Does it fit all SLIs?
&lt;/h2&gt;

&lt;p&gt;The SLI used as an example along the chapter is availability SLI but it clarified there that:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“error budgets” and “error rates” apply to all SLIs, not just those with “error” in their name.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Even though, it seems not so trivial to implement the above solution on other SLIs, specifically for latency SLI. Fortunately, there is a &lt;a href="https://www.youtube.com/watch?v=X99X-VDzxnw" rel="noopener noreferrer"&gt;great session&lt;/a&gt; by Björn Rabenstein that elaborates on how this solution can be implemented on latency SLI too.&lt;/p&gt;
&lt;h2&gt;
  
  
  Does it fit all SLOs?
&lt;/h2&gt;

&lt;p&gt;Chapter 5 uses as an example an SLO of 99.9 % and Björn Rabenstein takes examples of 99.9% and 99.5 % in his session. The lowest SLO I found as a demonstration of this alerting setup was in Yuri Grinshteyn's &lt;a href="https://medium.com/google-cloud/how-to-alert-on-slos-2a5ce8c4e7dd" rel="noopener noreferrer"&gt;post&lt;/a&gt; where he used an availability SLO of 95 %. But even if we take this relatively low SLO we still can alert on the highest burn rate of this setup: 14.4x for the 1-hour window, since 14.4 × 5 % = 70 %. Indeed, 70 % is a very high threshold, but taking into account that this relatively low SLO defines allowable 2,160 (!) minutes of downtime in a 30-days window, it makes complete sense. The math doesn’t lie: only if the actual error rate will be higher than 70 % in one hour we will get consumption of 2 % of the error budget and below that we don’t want (or need) to be notified unless this occurs on longer time windows, which will be caught by the other 2 longer windows (that are defined on lower burn rates).&lt;/p&gt;
&lt;h3&gt;
  
  
  Typical Latency SLOs
&lt;/h3&gt;

&lt;p&gt;As opposed to availability SLOs wherein most of the cases will be defined on the range between 2 nines (99 %) to 5 nines (99.999 %), latency SLOs can be on lower percentiles of the total requests, particularly when we want to capture both the typical user experience and the long tail, as recommended in chapter 2 of the SRE workbook, &lt;a href="https://sre.google/workbook/implementing-slos/" rel="noopener noreferrer"&gt;Implementing SLOs&lt;/a&gt;. In this chapter, two latency SLOs are defined:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;90 % of requests &amp;lt; 450 ms&lt;/li&gt;
&lt;li&gt;99 % of requests &amp;lt; 900 ms&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  The First Limitation: SLO’s Lower Bound
&lt;/h3&gt;

&lt;p&gt;Applying a 14.4x burn rate to the second one is straightforward: The SLO error rate is 1%, hence the threshold is 14.4 %. But if we try to apply this burn rate to the first one… well, I suppose you already did the math: we get a threshold of 144 %, meaning that even if all the requests in the last hour are slower than 450 ms, we still didn’t consume 2 % of the error budget but only ~1.39 % (since the burn rate is only 10x).&lt;/p&gt;

&lt;p&gt;So what can we do? We still want to use the powerful mechanism of alerting on different error budget consumptions. However, the above scenario reveals a lower bound on the minimal SLOs we can alert on using this solution. This lower bound can be calculated easily as 100% – 100%÷14.4 ≅ 93.06 %. Of course, we cannot limit ourselves to this bound, especially when dealing with latency SLOs.&lt;/p&gt;
&lt;h3&gt;
  
  
  The 2nd Limitation: Services With Varying Traffic
&lt;/h3&gt;

&lt;p&gt;Notice that the above limitation stems from the fact that we not alerting directly on the error budget but rather on the error rate which is expressed in percentages. On one hand, it seems the natural choice because we care about our SLOs, which are percentages by definition. On the other hand, alerting on percentages not only limits our ability to alert on SLOs lower than 93 % but also can introduce another limitation for all those services with varying traffic volumes (night vs day, business days vs weekends, etc.).&lt;/p&gt;

&lt;p&gt;The problem of using this solution with varying-traffic services is that we can easily get false alarms or miss real incidents. Specifically, in service with high traffic at day and low traffic at night, we can get a lot of false alarms at night, since even if we pass the error rate threshold (which is expressed in percent), probably the absolute number of bad requests will be lower or much lower than 2 % of the error budget. On the contrary, at peak hours, where the number of requests can be much higher than the average, we can still be under the error rate percentage threshold but exceed the 2 % error budget threshold.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Solution: Alert Directly on Error Budgets
&lt;/h2&gt;

&lt;p&gt;Indeed, chapter 5 mentions the case of services with low or varying traffic and suggests some solutions such as generating artificial traffic or combining several services into a larger one for monitoring purposes. However, the accompanying discussion is focused mainly on low-traffic services and not on those with varying traffic. Moreover, these proposed solutions may solve only the second problem and lead to unnecessary overhead.&lt;/p&gt;

&lt;p&gt;My proposed solution is surprisingly simple and solves both problems: &lt;strong&gt;Instead of alerting on the error rate, alert directly on the error budget!&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Why
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Solving Problem 1 - SLO lower bound&lt;/strong&gt; : Notice that this problem stems from the transformation (through the burn rate) of a natural number - the error budget, which is unbounded, to a ratio - the error rate, which is bounded in the range (0, 100 %]. Since we alert directly on the error budget we remain in the unbounded range and the 93 % SLO lower bound becomes irrelevant.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Solving Problem 2 - services with varying traffic&lt;/strong&gt; : By alerting directly on the error budget we’ll get alerts in low-traffic periods only where there are enough requests and a very high error rate, hence decreasing the number of false alarms. On the other hand, at peak hours we won’t miss real incidents since the alert will fire immediately when we reach 2 % of the error budget, even if the error rate is relatively small (less than 14.4x).&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  How
&lt;/h3&gt;

&lt;p&gt;To demonstrate how we can alert on error budget let’s return to the example of 30-day latency SLO of 90% of requests &amp;lt; 450 ms. We can easily measure the total number of requests in the past 30 days and multiply it by the complementary of the SLO, 10 %, to get the error budget which is the total number of allowable bad requests (slower than 450 ms) in the above period. For example, suppose the total number of requests in the last 30 days is 1,000,000, then we allow 100,000 requests to be slower than 450 ms in 30 days period. 2 % of this error budget is 2,000 requests and this will be our threshold for the 1-hour window, namely, we will alert only if more than 2000 requests in the last hour and more than 167 requests in the last 5 minutes are slower than 450 ms.&lt;/p&gt;

&lt;p&gt;Now, let’s implement it using &lt;a href="https://prometheus.io/" rel="noopener noreferrer"&gt;Prometheus syntax&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;Measuring the total number of requests in the past 30 (or 28) days can be done by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sum by (job) (increase(http_requests_total[30d]))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;To use it in our threshold expression we should set it as a recording rule:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- record: job:http_requests_total:increase30d  
  expr: sum by (job) (increase(http_requests_total[30d]))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now, since we want to alert on the error budget, which is the total &lt;em&gt;absolute&lt;/em&gt; number of allowable bad requests in the SLO period, we need a recording rule to count those bad requests for all long and short windows. For example, for the 1-hour window the recording rule will be as follows:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
where we simply subtract the number of requests that are faster than 450 ms from the total number of requests.&lt;/p&gt;

&lt;p&gt;Now all is left is to create alerting rule on it :&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
where we calculate 10 % of the total number of requests to get the error budget and multiply it by 0.02 to get the desired threshold of 2 % of the error budget. Notice that for the short window I divided the 2 % by 12 since this is the ratio between all the long windows to the short ones.

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this post, I presented two limitations in Google’s solution for alerting on SLOs as detailed in chapter 5 in Google’s SRE workbook. Those limitations are expressed at relatively low SLOs and/or services with varying traffic. To solve those problems I suggested alerting directly on the error budget as a simple yet powerful solution that eliminates both of those limitations with no additional effort.&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://dev.to/yairst/error-budget-is-all-you-need-part-2-3inb"&gt;next part&lt;/a&gt; I will show mathematically why Google’s solution is not suitable for varying-traffic services and how we can still alert on error rate, but do it correctly.&lt;/p&gt;

&lt;p&gt;Thanks to Ofri Oren, , and Omer Stark for their reviews.&lt;/p&gt;

</description>
      <category>sre</category>
      <category>slo</category>
      <category>errorbudget</category>
      <category>monitoring</category>
    </item>
  </channel>
</rss>
