feat: metrics endpoint for monitoring#64
Conversation
|
please resolve the conflicts |
|
@greatest0fallt1me I have a few merge conflicts here, mostly in the package.json and lockfile. My laptop is currently dead and I'm waiting for power/charge to get back online. I’ll resolve these as soon as I’m back at my desk to ensure the lockfile stays perfectly in sync and the JSON remains valid. Thanks for your patience!" |
|
@greatest0fallt1me I have successfully resolved the merge conflicts! The metrics Please note: The CI build will likely fail because the recent commits to main introduced several strict TypeScript errors in the src/webhooks and src/events directories (missing .js extensions for ESM imports, and an err.message unknown type). I left those files untouched so as not to step on your toes, but my metrics code is resolved and ready to go |
|
@greatest0fallt1me I have cleanly resolved the merge conflicts here! I manually consolidated the package.json dependencies and completely regenerated the package-lock.json to ensure there are no corrupted dependency trees. Just a heads-up regarding the failing CI check: it is failing for the exact same reason as the Metrics PR. The CI pipeline is catching the TypeScript compilation errors (missing .js extensions and implicit any types) present in the src/webhooks and src/events directories that currently exist on main. The isolated repository test suite itself is 100% intact and ready to go once the main branch stabilizes. Let me know if you need any adjustments to the repo logic in the meantime! |
Summary
This PR implements a standard Prometheus text-format metrics endpoint to provide comprehensive API observability and Node.js system monitoring.
Related Issue
Closes #59
Changes Implemented
prom-clientto expose standard Node.js system metrics (CPU, Memory, Event Loop Lag).http_requests_total(Counter) andhttp_request_duration_seconds(Histogram).req.route.pathinstead ofreq.path) to ensure dynamic IDs (e.g.,/api/users/123) do not leak PII or cause Prometheus cardinality explosions. Fallback regex is included for unmatched 404 routes./api/metricsendpoint requires a Bearer token matching theMETRICS_API_KEYenvironment variable whenNODE_ENV=production.Verification
Verified locally.
curl http://localhost:3000/api/metricssuccessfully returns the Prometheus payload with correctly labeled route traffic.