Slo Implementation

Slo Implementation

Explains how to define and implement SLIs, SLOs and error budgets with Prometheus queries and SLO-based alerting for reliability targets.

Skill files2 files

references/

SKILL.md271 lines
1
---
2
name: slo-implementation
3
description: Define and implement Service Level Indicators (SLIs) and Service Level Objectives (SLOs) with error budgets and alerting. Use when establishing reliability targets, implementing SRE practices, or measuring service performance.
4
---
5
6
# SLO Implementation
7
8
Framework for defining and implementing Service Level Indicators (SLIs), Service Level Objectives (SLOs), and error budgets.
9
10
## Purpose
11
12
Implement measurable reliability targets using SLIs, SLOs, and error budgets to balance reliability with innovation velocity.
13
14
## When to Use
15
16
- Define service reliability targets
17
- Measure user-perceived reliability
18
- Implement error budgets
19
- Create SLO-based alerts
20
- Track reliability goals
21
22
## SLI/SLO/SLA Hierarchy
23
24
```
25
SLA (Service Level Agreement)
26
↓ Contract with customers
27
SLO (Service Level Objective)
28
↓ Internal reliability target
29
SLI (Service Level Indicator)
30
↓ Actual measurement
31
```
32
33
## Defining SLIs
34
35
### Common SLI Types
36
37
#### 1. Availability SLI
38
39
```promql
40
# Successful requests / Total requests
41
sum(rate(http_requests_total{status!~"5.."}[28d]))
42
/
43
sum(rate(http_requests_total[28d]))
44
```
45
46
#### 2. Latency SLI
47
48
```promql
49
# Requests below latency threshold / Total requests
50
sum(rate(http_request_duration_seconds_bucket{le="0.5"}[28d]))
51
/
52
sum(rate(http_request_duration_seconds_count[28d]))
53
```
54
55
#### 3. Durability SLI
56
57
```
58
# Successful writes / Total writes
59
sum(storage_writes_successful_total)
60
/
61
sum(storage_writes_total)
62
```
63
64
## Setting SLO Targets
65
66
### Availability SLO Examples
67
68
| SLO % | Downtime/Month | Downtime/Year |
69
| ------ | -------------- | ------------- |
70
| 99% | 7.2 hours | 3.65 days |
71
| 99.9% | 43.2 minutes | 8.76 hours |
72
| 99.95% | 21.6 minutes | 4.38 hours |
73
| 99.99% | 4.32 minutes | 52.56 minutes |
74
75
### Choose Appropriate SLOs
76
77
**Consider:**
78
79
- User expectations
80
- Business requirements
81
- Current performance
82
- Cost of reliability
83
- Competitor benchmarks
84
85
**Example SLOs:**
86
87
```yaml
88
slos:
89
- name: api_availability
90
target: 99.9
91
window: 28d
92
sli: |
93
sum(rate(http_requests_total{status!~"5.."}[28d]))
94
/
95
sum(rate(http_requests_total[28d]))
96
97
- name: api_latency_p95
98
target: 99
99
window: 28d
100
sli: |
101
sum(rate(http_request_duration_seconds_bucket{le="0.5"}[28d]))
102
/
103
sum(rate(http_request_duration_seconds_count[28d]))
104
```
105
106
## Error Budget Calculation
107
108
### Error Budget Formula
109
110
```
111
Error Budget = 1 - SLO Target
112
```
113
114
**Example:**
115
116
- SLO: 99.9% availability
117
- Error Budget: 0.1% = 43.2 minutes/month
118
- Current Error: 0.05% = 21.6 minutes/month
119
- Remaining Budget: 50%
120
121
### Error Budget Policy
122
123
```yaml
124
error_budget_policy:
125
- remaining_budget: 100%
126
action: Normal development velocity
127
- remaining_budget: 50%
128
action: Consider postponing risky changes
129
- remaining_budget: 10%
130
action: Freeze non-critical changes
131
- remaining_budget: 0%
132
action: Feature freeze, focus on reliability
133
```
134
135
## SLO Implementation
136
137
### Prometheus Recording Rules
138
139
```yaml
140
# SLI Recording Rules
141
groups:
142
- name: sli_rules
143
interval: 30s
144
rules:
145
# Availability SLI
146
- record: sli:http_availability:ratio
147
expr: |
148
sum(rate(http_requests_total{status!~"5.."}[28d]))
149
/
150
sum(rate(http_requests_total[28d]))
151
152
# Latency SLI (requests < 500ms)
153
- record: sli:http_latency:ratio
154
expr: |
155
sum(rate(http_request_duration_seconds_bucket{le="0.5"}[28d]))
156
/
157
sum(rate(http_request_duration_seconds_count[28d]))
158
159
- name: slo_rules
160
interval: 5m
161
rules:
162
# SLO compliance (1 = meeting SLO, 0 = violating)
163
- record: slo:http_availability:compliance
164
expr: sli:http_availability:ratio >= bool 0.999
165
166
- record: slo:http_latency:compliance
167
expr: sli:http_latency:ratio >= bool 0.99
168
169
# Error budget remaining (percentage)
170
- record: slo:http_availability:error_budget_remaining
171
expr: |
172
(sli:http_availability:ratio - 0.999) / (1 - 0.999) * 100
173
174
# Error budget burn rate
175
- record: slo:http_availability:burn_rate_5m
176
expr: |
177
(1 - (
178
sum(rate(http_requests_total{status!~"5.."}[5m]))
179
/
180
sum(rate(http_requests_total[5m]))
181
)) / (1 - 0.999)
182
```
183
184
### SLO Alerting Rules
185
186
```yaml
187
groups:
188
- name: slo_alerts
189
interval: 1m
190
rules:
191
# Fast burn: 14.4x rate, 1 hour window
192
# Consumes 2% error budget in 1 hour
193
- alert: SLOErrorBudgetBurnFast
194
expr: |
195
slo:http_availability:burn_rate_1h > 14.4
196
and
197
slo:http_availability:burn_rate_5m > 14.4
198
for: 2m
199
labels:
200
severity: critical
201
annotations:
202
summary: "Fast error budget burn detected"
203
description: "Error budget burning at {{ $value }}x rate"
204
205
# Slow burn: 6x rate, 6 hour window
206
# Consumes 5% error budget in 6 hours
207
- alert: SLOErrorBudgetBurnSlow
208
expr: |
209
slo:http_availability:burn_rate_6h > 6
210
and
211
slo:http_availability:burn_rate_30m > 6
212
for: 15m
213
labels:
214
severity: warning
215
annotations:
216
summary: "Slow error budget burn detected"
217
description: "Error budget burning at {{ $value }}x rate"
218
219
# Error budget exhausted
220
- alert: SLOErrorBudgetExhausted
221
expr: slo:http_availability:error_budget_remaining < 0
222
for: 5m
223
labels:
224
severity: critical
225
annotations:
226
summary: "SLO error budget exhausted"
227
description: "Error budget remaining: {{ $value }}%"
228
```
229
230
## SLO Dashboard
231
232
**Grafana Dashboard Structure:**
233
234
```
235
┌────────────────────────────────────┐
236
│ SLO Compliance (Current) │
237
│ ✓ 99.95% (Target: 99.9%) │
238
├────────────────────────────────────┤
239
│ Error Budget Remaining: 65% │
240
│ ████████░░ 65% │
241
├────────────────────────────────────┤
242
│ SLI Trend (28 days) │
243
│ [Time series graph] │
244
├────────────────────────────────────┤
245
│ Burn Rate Analysis │
246
│ [Burn rate by time window] │
247
└────────────────────────────────────┘
248
```
249
250
**Example Queries:**
251
252
```promql
253
# Current SLO compliance
254
sli:http_availability:ratio * 100
255
256
# Error budget remaining
257
slo:http_availability:error_budget_remaining
258
259
# Days until error budget exhausted (at current burn rate)
260
(slo:http_availability:error_budget_remaining / 100)
261
*
262
28
263
/
264
(1 - sli:http_availability:ratio) * (1 - 0.999)
265
```
266
267
## Additional patterns and templates
268
269
More detailed templates and worked examples live in `references/details.md`. Read that file for the full pattern library.
270
271

© Seth Hobson · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 6,373 prompts

More by @OpenSourceBuffGuy

See all
Website Clone Architect prompt image

Website Clone Architect

Reverse-engineers a website section by section, writes component specs, and hands them to parallel builder agents in git worktrees to rebuild it.

agent-skill, orchestrator, parallel-agents, multi-agent, plan-then-execute, web-development, frontend, codebase-analysis, scaffolding, css, html, nextjs, typescript, git, mcp, claude-code, for-developers, for-designers, long-form, advanced, technical-spec, task-decomposition, structured-output, design-systems, ui-ux, tool-use, checklist, report, vibe-coding

Italian Terrace Cafe Candid Portrait prompt image

Italian Terrace Cafe Candid Portrait

Generates a photorealistic candid shot of a woman in a white corset dress laughing at a sunny hotel terrace cafe, written as detailed JSON.

image-prompt, json-prompt, structured-output, photorealistic, portrait, woman, candid, fashion, cottagecore, natural-light, golden-hour, bokeh, summer, travel, cityscape, mountains, medium-shot, vibrant-colors, for-photographers, nano-banana, fashion-shoot, luxury

Night Street Photo With Leashed Cat prompt image

Night Street Photo With Leashed Cat

Generates a flash-lit night street photo of a blonde woman in a retro track jacket walking a hissing tabby cat on a leash.

image-prompt, json-prompt, nano-banana, structured-output, portrait, woman, animals, pet-portrait, night-scene, street-photography, candid, editorial, fashion, dramatic-lighting, photorealistic, vertical-format, medium-shot, graffiti, for-photographers, for-content-creators

1 view

Reviews

Loading reviews…

Discussion

Loading comments…