<ol>
<li><p>Yes, you are interpreting that correctly.</p></li>
<li><p>When you express your SLO as a percentage, you should express your error rate as a percentage too. So, in you example your error rate of 1 is 100%. That would make the equation:</p>

<pre><code>(100-95/100) * 1 hour * 1 = 0.05 hours = 3 minutes
</code></pre></li>
<li><p>The period in that equation is the reporting period that you have chosen for your SLO. You have not mentioned what time period you chose. The examples in the workbook are 30 days. If you use a 30 day (720 hour) period in your example, you would consume approximately 0.14% of your error budget in the 3 minutes it takes for the alert to fire:</p>

<pre><code>( 1 * 1 hour ) / 720 hours = 0.14%
</code></pre></li>
<li><p>The rates are different because they are measured over different time periods. (Note that the graph is using a logarithmic scale, so the actual error rate and the peak of the 5m measurement is 15%, not 10%.)</p>

<ul>
<li>Consider what you would measure one minute after the errors started:

<ul>
<li>The 5m measurement would see 4 minutes of no errors plus one minute of 15% errors, which gives an overall error rate of 3%.</li>
<li>The 60m measurement would see 59 minutes of no errors plus one minute of 15% errors, which is just an overall error rate of 0.25%.</li>
</ul></li>
<li>Then 5 minutes after the errors started:

<ul>
<li>The 5m measurement would see 5 minutes of 15% errors, so the overall rate would be 15%.</li>
<li>The 60m measurement would see 55 minutes of no errors plus 5 minutes of 15% errors, so the overall rate would be 1.25%. This is actually still too low to trigger the alert, so it will actually take more than 5 minutes to alert.</li>
</ul></li>
<li><p>Using the equation from before, the actual time taken to alert is 5.76 minutes:</p>

<pre><code>5.76 = (0.001/0.15) * 60 * 14.4
</code></pre></li>
</ul></li>
<li><p>Your PromQL seems to be looking at the good events instead of the bad events, as the le="2" selector is for the bucket counting latencies <em>less than or equal to</em> (le) 2 seconds. You may want to create a separate "good_latency_rate1h" recording rule for the good events, and then use something like "(1-good_latency_rate1h) > (14.4*0.001)" for your alerts.</p></li>
</ol>

CC BY-SA 4.0
2020-02-28T15:01:31.340Z
2020-02-28T15:01:31.340Z
Marty Pauley
<p>I've read the Google SRE book a few times but I need some clarifications on exactly how to set up the burn rate and understanding how long it'll take to trigger an alert.</p>

<p>Most of my questions are specifically from this section on the book: <a href="https://landing.google.com/sre/workbook/chapters/alerting-on-slos/#4-alert-on-burn-rate" rel="noreferrer">https://landing.google.com/sre/workbook/chapters/alerting-on-slos/#4-alert-on-burn-rate</a></p>

<ol>
<li><p><a href="https://landing.google.com/sre/workbook/chapters/alerting-on-slos/#burn_rates_and_time_to_complete_budget_ex" rel="noreferrer">In Table 5-4</a>, the error rate for 99.9% SLO for burn rate of 1 is equal to 0.1%. I just want to confirm - this 0.1% is coming from 100% - 99.9% where 99.9% is the SLO. Does this mean if some service has a ridiculously lower SLO, (say 90% SLO), then their error rate for burn rate of 1 would be 10%. Am I interpreting this properly?</p></li>
<li><p>Couple sentences below, the book says </p></li>
</ol>

<blockquote>
  <p>For burn rate-based alerts, the time taken for an alert to fire is (1-SLO/error ratio) * alerting window size * burn rate.</p>
</blockquote>

<p>So if my SLO is 95%, and my error rate is 1 (let's assume all the requests coming up in last 1 hour are errors). Let's assume my burn rate is 1. If I plug these values into the formula, I am getting, </p>

<pre><code>(100-95/1) * 1 hour * 1 = 5.
</code></pre>

<p>This is where my confusion is. Is this 5 hours? Do you convert 1 hour into 60 minutes to get the minutes? Is that how long it'll take Prometheus to fire the first alert?</p>

<p>Furthermore, isn't the detection time too late if it will take 5 hours to get an alert? Maybe some concrete examples on how you use this formula to calculate some real values would be really helpful.</p>

<ol start="3">
<li>The next formula, </li>
</ol>

<blockquote>
  <p>The error budget consumed by the time the alert fires is: (burn rate * alerting window size)/period.</p>
</blockquote>

<p>Just want to clarify this - if my burn rate is 1 and my alerting window size is 1 hour, this means, within 5 hours, I would have consumed, (1 * 1)/5 = 20% of my error budget. </p>

<p>Is this right?</p>

<ol start="4">
<li><a href="https://landing.google.com/sre/workbook/chapters/alerting-on-slos/#recommended_parameters_for_an_slo_based_a" rel="noreferrer">The table 5-8</a> has recommendations to send an alert if the long window is 1 hour and the short window is 5 minutes and if the burn rate is 14.4 and the error budget consumed is 2%. </li>
</ol>

<p>In the graph above, it shows that the error rate for 5 minutes (10%) is higher than the error rate for 1 hour. Why would their error rates be different if the burn rate is same = 14.4? I'm having difficulty understanding this bit.</p>

<p>It also says it will take 5 minutes to alert based on this information. Will this be true for any SLO? Or is it only true for 99.9% SLO?</p>

<ol start="5">
<li>And lastly, just wanted to clarify: The examples in the chapter use this following recording rule, which is for ratio of errors per request.</li>
</ol>

<blockquote>
  <p>job:slo_errors_per_request:ratio_rate1h{job="myjob"} > (14.4*0.001)</p>
</blockquote>

<p>If I want to something similar for identifying latency - i.e. ratio of all requests which have a latency of more than 2 seconds, then this would be the following PromQL:</p>

<pre><code>(sum by (job, le) (rate(latency_quantile{job="myjob", le="2"}[1h])) 
/
sum by (job, le) (rate(request_count{job="myjob"}[1h]))) &gt; (14.4 * 0.001)
</code></pre>

<p>Does this look right?</p>

<p>Bottom line, I wish this particular chapter, which the authors acknowledge that it has some complex implementations, had some more concrete examples especially around the formulae and the burn rate. Some examples specified in the tables and chart make sense. But some need a little more clarification to understand the nuances (e.g. specifying that a burn rate of 14.4 translates into 2% of the error budget and this is because when you divide by 30/14.4, you get 50 hours of error budget, and 1 hour is 2% of those 50 hours.)</p>

CC BY-SA 4.0
2019-08-16T11:44:54.203Z
It would be great if @steven-thurgood (and any one else who understands these really well) can help.
BlueChips23
CC BY-SA 4.0
2019-12-26T09:30:24.820Z
Please describe where SLO stands for
030
<prometheus><sre>
How to calculate burn rate for SLOs?
BlueChips23
# How to calculate burn rate for SLOs?

(Asked by: username_0 on 2019-08-16)

I've read the Google SRE book a few times but I need some clarifications on exactly how to set up the burn rate and understanding how long it'll take to trigger an alert.
Most of my questions are specifically from this section on the book: https://landing.google.com/sre/workbook/chapters/alerting-on-slos/#4-alert-on-burn-rate

In Table 5-4, the error rate for 99.9% SLO for burn rate of 1 is equal to 0.1%. I just want to confirm - this 0.1% is coming from 100% - 99.9% where 99.9% is the SLO. Does this mean if some service has a ridiculously lower SLO, (say 90% SLO), then their error rate for burn rate of 1 would be 10%. Am I interpreting this properly?
Couple sentences below, the book says 


For burn rate-based alerts, the time taken for an alert to fire is (1-SLO/error ratio) * alerting window size * burn rate.

So if my SLO is 95%, and my error rate is 1 (let's assume all the requests coming up in last 1 hour are errors). Let's assume my burn rate is 1. If I plug these values into the formula, I am getting, 
(100-95/1) * 1 hour * 1 = 5.

This is where my confusion is. Is this 5 hours? Do you convert 1 hour into 60 minutes to get the minutes? Is that how long it'll take Prometheus to fire the first alert?
Furthermore, isn't the detection time too late if it will take 5 hours to get an alert? Maybe some concrete examples on how you use this formula to calculate some real values would be really helpful.

The next formula, 


The error budget consumed by the time the alert fires is: (burn rate * alerting window size)/period.

Just want to clarify this - if my burn rate is 1 and my alerting window size is 1 hour, this means, within 5 hours, I would have consumed, (1 * 1)/5 = 20% of my error budget. 
Is this right?

The table 5-8 has recommendations to send an alert if the long window is 1 hour and the short window is 5 minutes and if the burn rate is 14.4 and the error budget consumed is 2%. 

In the graph above, it shows that the error rate for 5 minutes (10%) is higher than the error rate for 1 hour. Why would their error rates be different if the burn rate is same = 14.4? I'm having difficulty understanding this bit.
It also says it will take 5 minutes to alert based on this information. Will this be true for any SLO? Or is it only true for 99.9% SLO?

And lastly, just wanted to clarify: The examples in the chapter use this following recording rule, which is for ratio of errors per request.


job:slo_errors_per_request:ratio_rate1h{job="myjob"} > (14.4*0.001)

If I want to something similar for identifying latency - i.e. ratio of all requests which have a latency of more than 2 seconds, then this would be the following PromQL:
(sum by (job, le) (rate(latency_quantile{job="myjob", le="2"}[1h])) 
/
sum by (job, le) (rate(request_count{job="myjob"}[1h]))) > (14.4 * 0.001)

Does this look right?
Bottom line, I wish this particular chapter, which the authors acknowledge that it has some complex implementations, had some more concrete examples especially around the formulae and the burn rate. Some examples specified in the tables and chart make sense. But some need a little more clarification to understand the nuances (e.g. specifying that a burn rate of 14.4 translates into 2% of the error budget and this is because when you divide by 30/14.4, you get 50 hours of error budget, and 1 hour is 2% of those 50 hours.)

**Tags:** prometheus, sre

> **Comments:**
> **username_0**: It would be great if @steven-thurgood (and any one else who understands these really well) can help.  
> **username_1**: Please describe where SLO stands for  

---

## 1 answers

### Answer by username_2 on 2020-02-28. Score: 8 | Accepted answer

Yes, you are interpreting that correctly.
When you express your SLO as a percentage, you should express your error rate as a percentage too. So, in you example your error rate of 1 is 100%. That would make the equation:
(100-95/100) * 1 hour * 1 = 0.05 hours = 3 minutes

The period in that equation is the reporting period that you have chosen for your SLO. You have not mentioned what time period you chose. The examples in the workbook are 30 days. If you use a 30 day (720 hour) period in your example, you would consume approximately 0.14% of your error budget in the 3 minutes it takes for the alert to fire:
( 1 * 1 hour ) / 720 hours = 0.14%

The rates are different because they are measured over different time periods. (Note that the graph is using a logarithmic scale, so the actual error rate and the peak of the 5m measurement is 15%, not 10%.)

Consider what you would measure one minute after the errors started:


The 5m measurement would see 4 minutes of no errors plus one minute of 15% errors, which gives an overall error rate of 3%.
The 60m measurement would see 59 minutes of no errors plus one minute of 15% errors, which is just an overall error rate of 0.25%.

Then 5 minutes after the errors started:


The 5m measurement would see 5 minutes of 15% errors, so the overall rate would be 15%.
The 60m measurement would see 55 minutes of no errors plus 5 minutes of 15% errors, so the overall rate would be 1.25%. This is actually still too low to trigger the alert, so it will actually take more than 5 minutes to alert.

Using the equation from before, the actual time taken to alert is 5.76 minutes:
5.76 = (0.001/0.15) * 60 * 14.4


Your PromQL seems to be looking at the good events instead of the bad events, as the le="2" selector is for the bucket counting latencies less than or equal to (le) 2 seconds. You may want to create a separate "good_latency_rate1h" recording rule for the good events, and then use something like "(1-good_latency_rate1h) > (14.4*0.001)" for your alerts.


---

