-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathprometheus-rules.yml
More file actions
179 lines (156 loc) · 5.67 KB
/
prometheus-rules.yml
File metadata and controls
179 lines (156 loc) · 5.67 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
# prometheus-rules.yml
# Alert rules for LumenPulse backend monitoring
#
# These rules define when alerts should fire based on metric conditions
# Place this file in the root directory and reference it in prometheus.yml
groups:
- name: lumenpulse_alerts
interval: 30s
rules:
# ===================
# HTTP Error Alerts
# ===================
- alert: HighErrorRate
expr: |
(rate(http_errors_total[5m]) / rate(http_requests_total[5m])) > 0.05
for: 5m
labels:
severity: warning
service: backend
annotations:
summary: 'High error rate detected'
description: '{{ .Labels.instance }} has error rate > 5% (current: {{ $value | humanizePercentage }})'
runbook: 'https://wiki.example.com/runbooks/high-error-rate'
- alert: CriticalErrorRate
expr: |
(rate(http_errors_total[5m]) / rate(http_requests_total[5m])) > 0.10
for: 2m
labels:
severity: critical
service: backend
annotations:
summary: 'Critical error rate detected'
description: '{{ .Labels.instance }} has error rate > 10% (current: {{ $value | humanizePercentage }})'
runbook: 'https://wiki.example.com/runbooks/critical-error-rate'
# ===================
# Latency Alerts
# ===================
- alert: HighLatencyP95
expr: |
histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])) > 1
for: 5m
labels:
severity: warning
service: backend
annotations:
summary: 'High P95 latency detected'
description: '{{ .Labels.instance }} P95 latency > 1s (current: {{ $value | humanizeDuration }})'
runbook: 'https://wiki.example.com/runbooks/high-latency'
- alert: HighLatencyP99
expr: |
histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m])) > 3
for: 5m
labels:
severity: critical
service: backend
annotations:
summary: 'Critical P99 latency detected'
description: '{{ .Labels.instance }} P99 latency > 3s (current: {{ $value | humanizeDuration }})'
runbook: 'https://wiki.example.com/runbooks/critical-latency'
# ====================
# Job Queue Alerts
# ====================
- alert: QueueBacklogWarning
expr: job_queue_size > 100
for: 10m
labels:
severity: warning
service: backend
annotations:
summary: 'Job queue backlog warning'
description: '{{ .Labels.queue_name }} queue has {{ $value }} jobs pending'
- alert: QueueBacklogCritical
expr: job_queue_size > 1000
for: 5m
labels:
severity: critical
service: backend
annotations:
summary: 'Critical job queue backlog'
description: '{{ .Labels.queue_name }} queue has {{ $value }} jobs (critical backlog)'
- alert: JobFailureRate
expr: |
rate(jobs_failed_total[5m]) > 0.1
for: 5m
labels:
severity: warning
service: backend
annotations:
summary: 'High job failure rate'
description: '{{ .Labels.queue_name }} has > 10% job failures (current: {{ $value | humanize }}/sec)'
# ====================
# Request Rate Alerts
# ====================
- alert: UnusuallyLowRequestRate
expr: |
rate(http_requests_total[5m]) < 0.1
for: 10m
labels:
severity: warning
service: backend
annotations:
summary: 'Unusually low request rate'
description: '{{ .Labels.instance }} request rate is abnormally low ({{ $value | humanize }}/sec)'
- alert: NoRequests
expr: |
increase(http_requests_total[5m]) == 0
for: 10m
labels:
severity: critical
service: backend
annotations:
summary: 'No requests detected'
description: '{{ .Labels.instance }} has received no requests in the last 5 minutes'
# ====================
# Memory Alerts
# ====================
- alert: HighMemoryUsage
expr: |
(process_resident_memory_bytes / node_memory_MemTotal_bytes) > 0.8
for: 5m
labels:
severity: warning
service: backend
annotations:
summary: 'High memory usage detected'
description: '{{ .Labels.instance }} is using > 80% of available memory'
# ====================
# Health Checks
# ====================
- alert: InstanceDown
expr: |
up{job="lumenpulse-backend"} == 0
for: 1m
labels:
severity: critical
service: backend
annotations:
summary: 'Instance is down'
description: '{{ .Labels.instance }} has been down for more than 1 minute'
# ====================
# Recording Rules (Pre-computed metrics)
# ====================
# These compute common values once to improve dashboard performance
- record: 'job:http:requests:rate5m'
expr: 'rate(http_requests_total[5m])'
- record: 'job:http:errors:rate5m'
expr: 'rate(http_errors_total[5m])'
- record: 'job:http:error_rate:ratio'
expr: |
rate(http_errors_total[5m]) / rate(http_requests_total[5m])
- record: 'job:http:latency:p95'
expr: |
histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m]))
- record: 'job:http:latency:p99'
expr: |
histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m]))