Skip to content

Commit 21cd325

Browse files
fix(observability): align alert rule unit tests with rule output
The promtool unit tests failed for two reasons: - HighP95Latency never fired: its highest finite histogram bucket was le=1000, so histogram_quantile capped at 1000 and could never exceed the >1000ms threshold. Add a le=2000 bucket so p95 lands above the SLO. - Every firing exp_alerts entry omitted the job label and exp_annotations the rules actually emit, so promtool reported label/annotation mismatches. Add the job label (where present) and full exp_annotations to each. promtool test rules now passes (16 rules, all unit tests green).
1 parent 17450eb commit 21cd325

1 file changed

Lines changed: 59 additions & 2 deletions

File tree

monitoring/alerting/alerting_rules_test.yml

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ tests:
2727
- exp_labels:
2828
severity: critical
2929
team: backend
30+
exp_annotations:
31+
summary: 'Trivela backend 5xx error rate above 5%'
32+
description:
33+
'Error rate is 10% over the last 5 minutes. Investigate backend logs immediately.'
34+
runbook_url: 'https://github.com/FinesseStudioLab/Trivela/blob/main/docs/RUNBOOK.md#backend-restart'
3035

3136
# ── HighBackendErrorRate does NOT fire below threshold ───────────────────
3237
- interval: 1m
@@ -42,15 +47,19 @@ tests:
4247
exp_alerts: []
4348

4449
# ── HighP95Latency ──────────────────────────────────────────────────────────
45-
# Simulate p95 > 1000ms: put most samples in the >1000 bucket.
50+
# Simulate p95 > 1000ms. The highest finite bucket must be above the 1000ms
51+
# threshold, otherwise histogram_quantile caps at le=1000 and the alert can
52+
# never fire — so most samples land in the (1000, 2000] bucket.
4653
- interval: 30s
4754
input_series:
4855
- series: 'trivela_http_request_duration_ms_bucket{job="trivela-backend",le="500"}'
4956
values: '0+10x20'
5057
- series: 'trivela_http_request_duration_ms_bucket{job="trivela-backend",le="1000"}'
5158
values: '0+11x20'
59+
- series: 'trivela_http_request_duration_ms_bucket{job="trivela-backend",le="2000"}'
60+
values: '0+100x20'
5261
- series: 'trivela_http_request_duration_ms_bucket{job="trivela-backend",le="+Inf"}'
53-
values: '0+100x20' # 89 out of 100 requests > 1000ms → p95 > 1000
62+
values: '0+100x20' # p95 lands in (1000, 2000] → > 1000ms SLO breach
5463

5564
alert_rule_test:
5665
- eval_time: 6m
@@ -59,6 +68,12 @@ tests:
5968
- exp_labels:
6069
severity: warning
6170
team: backend
71+
exp_annotations:
72+
summary: 'Trivela p95 request latency above 1 second'
73+
description:
74+
'The 95th-percentile request latency is 32m 23s — above the 1 s SLO target. Identify
75+
slow routes in Grafana → Trivela API dashboard.'
76+
runbook_url: 'https://github.com/FinesseStudioLab/Trivela/blob/main/docs/RUNBOOK.md#latency-investigation'
6277

6378
# ── BackendDown ──────────────────────────────────────────────────────────────
6479
- interval: 30s
@@ -71,8 +86,14 @@ tests:
7186
alertname: BackendDown
7287
exp_alerts:
7388
- exp_labels:
89+
job: trivela-backend
7490
severity: critical
7591
team: backend
92+
exp_annotations:
93+
summary: 'Trivela backend is unreachable'
94+
description:
95+
'Prometheus cannot scrape the backend /metrics endpoint. Service may be down.'
96+
runbook_url: 'https://github.com/FinesseStudioLab/Trivela/blob/main/docs/RUNBOOK.md#backend-restart'
7697

7798
# ── AllRpcEndpointsUnhealthy ────────────────────────────────────────────────
7899
- interval: 30s
@@ -85,8 +106,15 @@ tests:
85106
alertname: AllRpcEndpointsUnhealthy
86107
exp_alerts:
87108
- exp_labels:
109+
job: trivela-backend
88110
severity: critical
89111
team: infrastructure
112+
exp_annotations:
113+
summary: 'All Soroban RPC endpoints are unhealthy'
114+
description:
115+
'Every endpoint in the RPC pool is marked unhealthy. Contract interactions will fail
116+
or fall back to the first endpoint. Check RPC node health.'
117+
runbook_url: 'https://github.com/FinesseStudioLab/Trivela/blob/main/docs/RUNBOOK.md#rpc-failover'
90118

91119
# ── RpcPoolSaturated ────────────────────────────────────────────────────────
92120
- interval: 30s
@@ -99,8 +127,16 @@ tests:
99127
alertname: RpcPoolSaturated
100128
exp_alerts:
101129
- exp_labels:
130+
job: trivela-backend
102131
severity: warning
103132
team: backend
133+
exp_annotations:
134+
summary: 'RPC pool is saturated — callers waiting'
135+
description:
136+
'3 caller(s) are queued waiting for an RPC pool slot. Requests beyond the acquire
137+
timeout will receive 503 POOL_SATURATED. Consider increasing PG_POOL_MAX or scaling
138+
the RPC tier.'
139+
runbook_url: 'https://github.com/FinesseStudioLab/Trivela/blob/main/docs/RUNBOOK.md#rpc-pool-saturation'
104140

105141
# ── DLQGrowth ───────────────────────────────────────────────────────────────
106142
- interval: 1m
@@ -113,8 +149,15 @@ tests:
113149
alertname: DLQGrowth
114150
exp_alerts:
115151
- exp_labels:
152+
job: trivela-backend
116153
severity: warning
117154
team: backend
155+
exp_annotations:
156+
summary: 'Dead-letter queue is growing'
157+
description:
158+
'30 jobs added to the DLQ in the last 15 minutes. Background jobs are failing
159+
repeatedly. Review failed job logs for root cause.'
160+
runbook_url: 'https://github.com/FinesseStudioLab/Trivela/blob/main/docs/RUNBOOK.md#dlq-investigation'
118161

119162
# ── OperatorLowBalance ──────────────────────────────────────────────────────
120163
- interval: 1m
@@ -127,8 +170,15 @@ tests:
127170
alertname: OperatorLowBalance
128171
exp_alerts:
129172
- exp_labels:
173+
job: trivela-backend
130174
severity: warning
131175
team: contracts
176+
exp_annotations:
177+
summary: 'Operator wallet balance is low'
178+
description:
179+
'Operator XLM balance is 30M stroops (< 5 XLM). Transaction fees may fail. Top up
180+
the operator wallet immediately.'
181+
runbook_url: 'https://github.com/FinesseStudioLab/Trivela/blob/main/docs/RUNBOOK.md#operator-wallet-topup'
132182

133183
# ── CanaryJourneyFailed ─────────────────────────────────────────────────────
134184
- interval: 1m
@@ -141,5 +191,12 @@ tests:
141191
alertname: CanaryJourneyFailed
142192
exp_alerts:
143193
- exp_labels:
194+
job: trivela-canary
144195
severity: critical
145196
team: backend
197+
exp_annotations:
198+
summary: 'Synthetic canary journey failed'
199+
description:
200+
'The register→credit→claim canary on testnet has not succeeded for 5 minutes. Core
201+
user journey is broken. Check canary logs and RPC/contract health.'
202+
runbook_url: 'https://github.com/FinesseStudioLab/Trivela/blob/main/docs/RUNBOOK.md#canary-failure'

0 commit comments

Comments
 (0)