Add Prometheus /metrics endpoint#327
Conversation
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR adds Prometheus metrics support to the OpenWorkflow dashboard by introducing a new /metrics endpoint that exposes workflow run counts grouped by status. The implementation includes backend aggregation queries, a metrics server handler, comprehensive test coverage, and user documentation.
Changes:
- Added
countWorkflowRuns()method to Backend interface with implementations for PostgreSQL and SQLite - Created
/metricsendpoint in dashboard that serves Prometheus exposition format - Added comprehensive documentation for Prometheus integration with alert examples
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/openworkflow/backend.ts | Added WorkflowRunCounts type, countWorkflowRuns interface method, and toWorkflowRunCounts helper function for status aggregation |
| packages/openworkflow/sqlite/backend.ts | Implemented countWorkflowRuns with SQLite GROUP BY query |
| packages/openworkflow/postgres/backend.ts | Implemented countWorkflowRuns with PostgreSQL GROUP BY query |
| packages/openworkflow/backend.test.ts | Added unit tests for toWorkflowRunCounts function covering legacy "succeeded" status handling |
| packages/openworkflow/backend.testsuite.ts | Added integration tests for countWorkflowRuns covering empty state, status grouping, and transitions |
| packages/dashboard/src/lib/metrics.server.ts | Created metrics server handler using prom-client to generate Prometheus exposition format |
| packages/dashboard/src/lib/metrics.server.test.ts | Added tests for metrics endpoint covering format validation, caching behavior, and error handling |
| packages/dashboard/src/routes/metrics.ts | Added /metrics route definition |
| packages/dashboard/src/routeTree.gen.ts | Auto-generated route tree updates for new metrics route |
| packages/dashboard/package.json | Added prom-client v14.2.0 dependency |
| packages/docs/docs/prometheus.mdx | New documentation page with setup instructions, metrics reference, and PromQL alert examples |
| packages/docs/docs/production.mdx | Added reference to Prometheus metrics documentation |
| packages/docs/docs/dashboard.mdx | Added reference to Prometheus metrics documentation |
| packages/docs/docs.json | Added prometheus.mdx to documentation navigation |
| package-lock.json | Lock file updates for prom-client and dependencies (bintrees, tdigest) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d3ab6bb to
83fd3e0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 18 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
83fd3e0 to
68c9386
Compare
This PR adds a Prometheus metrics endpoint to the dashboard and the supporting backend queries to power it.
GET /metrics on the dashboard: