-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathprometheus-config.yaml
More file actions
372 lines (336 loc) · 12.9 KB
/
Copy pathprometheus-config.yaml
File metadata and controls
372 lines (336 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: estatewise
data:
prometheus.yml: |
global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s
external_labels:
cluster: 'estatewise-production'
environment: 'production'
alerting:
alertmanagers:
- static_configs:
- targets:
- alertmanager:9093
path_prefix: /
scheme: http
timeout: 10s
rule_files:
- /etc/prometheus/rules/*.yml
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'kubernetes-apiservers'
kubernetes_sd_configs:
- role: endpoints
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
relabel_configs:
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: default;kubernetes;https
- job_name: 'kubernetes-nodes'
kubernetes_sd_configs:
- role: node
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- job_name: 'kubernetes-pods'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
target_label: __address__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: kubernetes_pod_name
- job_name: 'estatewise-backend'
kubernetes_sd_configs:
- role: pod
namespaces:
names:
- estatewise
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app]
action: keep
regex: backend
- source_labels: [__meta_kubernetes_pod_container_port_number]
action: keep
regex: "5001"
- source_labels: [__meta_kubernetes_pod_name]
target_label: pod
- source_labels: [__meta_kubernetes_namespace]
target_label: namespace
- job_name: 'estatewise-frontend'
kubernetes_sd_configs:
- role: pod
namespaces:
names:
- estatewise
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app]
action: keep
regex: frontend
- source_labels: [__meta_kubernetes_pod_container_port_number]
action: keep
regex: "3000"
- source_labels: [__meta_kubernetes_pod_name]
target_label: pod
- source_labels: [__meta_kubernetes_namespace]
target_label: namespace
- job_name: 'node-exporter'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app]
action: keep
regex: node-exporter
- source_labels: [__meta_kubernetes_pod_node_name]
target_label: node
- job_name: 'mongodb-exporter'
kubernetes_sd_configs:
- role: service
relabel_configs:
- source_labels: [__meta_kubernetes_service_label_app]
action: keep
regex: mongodb-exporter
- source_labels: [__meta_kubernetes_service_name]
target_label: service
- job_name: 'redis-exporter'
kubernetes_sd_configs:
- role: service
relabel_configs:
- source_labels: [__meta_kubernetes_service_label_app]
action: keep
regex: redis-exporter
alerting_rules.yml: |
groups:
- name: estatewise_alerts
interval: 30s
rules:
- alert: HighErrorRate
expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.05
for: 5m
labels:
severity: critical
component: api
annotations:
summary: "High error rate detected"
description: "Error rate is {{ $value }} requests/sec on {{ $labels.instance }}"
- alert: HighLatency
expr: histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])) > 1
for: 5m
labels:
severity: warning
component: api
annotations:
summary: "High latency detected"
description: "95th percentile latency is {{ $value }}s on {{ $labels.instance }}"
- alert: PodDown
expr: up{job=~"estatewise-.*"} == 0
for: 2m
labels:
severity: critical
annotations:
summary: "Pod {{ $labels.pod }} is down"
description: "Pod {{ $labels.pod }} in namespace {{ $labels.namespace }} has been down for more than 2 minutes"
- alert: HighMemoryUsage
expr: (container_memory_usage_bytes / container_spec_memory_limit_bytes) > 0.9
for: 5m
labels:
severity: warning
annotations:
summary: "High memory usage"
description: "Container {{ $labels.container }} is using {{ $value | humanizePercentage }} of memory limit"
- alert: HighCPUUsage
expr: (rate(container_cpu_usage_seconds_total[5m]) / container_spec_cpu_quota) > 0.8
for: 10m
labels:
severity: warning
annotations:
summary: "High CPU usage"
description: "Container {{ $labels.container }} is using {{ $value | humanizePercentage }} of CPU limit"
- alert: DatabaseConnectionPoolExhausted
expr: mongodb_connections{state="current"} / mongodb_connections{state="available"} > 0.8
for: 5m
labels:
severity: warning
component: database
annotations:
summary: "Database connection pool nearly exhausted"
description: "MongoDB connection pool is {{ $value | humanizePercentage }} utilized"
- alert: DiskSpaceLow
expr: (node_filesystem_avail_bytes / node_filesystem_size_bytes) < 0.1
for: 5m
labels:
severity: warning
annotations:
summary: "Low disk space"
description: "Disk space is below 10% on {{ $labels.device }}"
- alert: PodCrashLooping
expr: rate(kube_pod_container_status_restarts_total[15m]) > 0
for: 5m
labels:
severity: critical
annotations:
summary: "Pod is crash looping"
description: "Pod {{ $labels.pod }} is restarting frequently"
sli_rules.yml: |
groups:
- name: sli_slo_rules
interval: 30s
rules:
- record: sli:availability:ratio
expr: |
sum(rate(http_requests_total{status!~"5.."}[5m])) /
sum(rate(http_requests_total[5m]))
- record: sli:latency:p95
expr: histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m]))
- record: sli:latency:p99
expr: histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m]))
- record: sli:error_rate
expr: |
sum(rate(http_requests_total{status=~"5.."}[5m])) /
sum(rate(http_requests_total[5m]))
- record: sli:throughput
expr: sum(rate(http_requests_total[5m]))
# Error budget recording rules
- record: sli:error_budget:remaining_ratio
expr: |
1 - (
(1 - avg_over_time(sli:availability:ratio[30d])) /
(1 - 0.999)
)
- record: sli:burn_rate:1h
expr: |
1 - (
sum(rate(http_requests_total{status!~"5.."}[1h])) /
sum(rate(http_requests_total[1h]))
)
/
(1 - 0.999)
- record: sli:burn_rate:6h
expr: |
1 - (
sum(rate(http_requests_total{status!~"5.."}[6h])) /
sum(rate(http_requests_total[6h]))
)
/
(1 - 0.999)
- record: sli:burn_rate:3d
expr: |
1 - (
sum(rate(http_requests_total{status!~"5.."}[3d])) /
sum(rate(http_requests_total[3d]))
)
/
(1 - 0.999)
- alert: SLOAvailabilityBreach
expr: sli:availability:ratio < 0.995
for: 5m
labels:
severity: critical
slo: availability
annotations:
summary: "SLO breach: Availability below 99.5%"
description: "Current availability: {{ $value | humanizePercentage }}"
- alert: SLOLatencyBreach
expr: sli:latency:p95 > 0.5
for: 5m
labels:
severity: critical
slo: latency
annotations:
summary: "SLO breach: p95 latency above 500ms"
description: "Current p95 latency: {{ $value }}s"
# Multi-window burn-rate alerts (Google SRE pattern)
- alert: SLOBurnRateCritical
expr: sli:burn_rate:1h > 14.4 and sli:burn_rate:6h > 6
for: 2m
labels:
severity: critical
slo: availability
window: multi
annotations:
summary: "Critical SLO burn rate - error budget exhausting fast"
description: "1h burn rate: {{ $value }}x budget. At this rate, 30-day error budget exhausts in {{ printf \"%.1f\" (div 720.0 $value) }} hours."
runbook: "https://estatewise.example.com/runbooks/slo-burn-rate"
- alert: SLOBurnRateWarning
expr: sli:burn_rate:6h > 6 and sli:burn_rate:3d > 3
for: 5m
labels:
severity: warning
slo: availability
window: multi
annotations:
summary: "Elevated SLO burn rate - investigate"
description: "6h burn rate: {{ $value }}x budget. Sustained burn will breach SLO within the 30-day window."
- alert: SLOBurnRateTrend
expr: sli:burn_rate:3d > 1
for: 30m
labels:
severity: info
slo: availability
window: trend
annotations:
summary: "SLO budget trending down"
description: "3d burn rate: {{ $value }}x budget. Error budget remaining: {{ printf \"%.1f\" (mul (query \"sli:error_budget:remaining_ratio\") 100) }}%"
- alert: SLOErrorBudgetLow
expr: sli:error_budget:remaining_ratio < 0.25
for: 5m
labels:
severity: warning
slo: error-budget
annotations:
summary: "Less than 25% error budget remaining"
description: "Only {{ $value | humanizePercentage }} of the 30-day error budget remains."
- alert: SLOErrorBudgetExhausted
expr: sli:error_budget:remaining_ratio < 0
for: 1m
labels:
severity: critical
slo: error-budget
annotations:
summary: "Error budget exhausted"
description: "The 30-day error budget is fully consumed. Freeze non-critical deployments."
# Latency burn-rate alerts
- alert: SLOLatencyBurnRateCritical
expr: |
(histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[1h])) > 0.5)
and
(histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[6h])) > 0.5)
for: 2m
labels:
severity: critical
slo: latency
window: multi
annotations:
summary: "Sustained P95 latency SLO breach across multiple windows"
description: "P95 latency exceeds 500ms in both 1h and 6h windows."