Skip to content

Add Prometheus /metrics endpoint#327

Merged
jamescmartinez merged 1 commit intomainfrom
prom-metrics
Feb 23, 2026
Merged

Add Prometheus /metrics endpoint#327
jamescmartinez merged 1 commit intomainfrom
prom-metrics

Conversation

@jamescmartinez
Copy link
Copy Markdown
Contributor

@jamescmartinez jamescmartinez commented Feb 23, 2026

This PR adds a Prometheus metrics endpoint to the dashboard and the supporting backend queries to power it.

Screenshot 2026-02-22 at 7 27 57 PM Screenshot 2026-02-22 at 7 27 22 PM

GET /metrics on the dashboard:

# HELP openworkflow_workflow_runs Current count of workflow runs in each status.
# TYPE openworkflow_workflow_runs gauge
openworkflow_workflow_runs{status="pending"} 0
openworkflow_workflow_runs{status="running"} 0
openworkflow_workflow_runs{status="sleeping"} 0
openworkflow_workflow_runs{status="completed"} 0
openworkflow_workflow_runs{status="failed"} 0
openworkflow_workflow_runs{status="canceled"} 0

Copilot AI review requested due to automatic review settings February 23, 2026 00:34
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 23, 2026

Open in StackBlitz

npm i https://pkg.pr.new/openworkflowdev/openworkflow/@openworkflow/cli@327
npm i https://pkg.pr.new/openworkflowdev/openworkflow/@openworkflow/dashboard@327
npm i https://pkg.pr.new/openworkflowdev/openworkflow@327

commit: 83fd3e0

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /metrics endpoint 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.

Comment thread packages/docs/docs/dashboard.mdx Outdated
Comment thread packages/openworkflow/backend.test.ts
Comment thread packages/openworkflow/backend.ts Outdated
Comment thread packages/docs/docs/production.mdx Outdated
Copilot AI review requested due to automatic review settings February 23, 2026 00:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/openworkflow/backend.test.ts Outdated
Comment thread packages/openworkflow/sqlite/backend.ts
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jamescmartinez jamescmartinez changed the title Add Prometheus metrics endpoint to dashboard Add Prometheus /metrics endpoint Feb 23, 2026
@jamescmartinez jamescmartinez merged commit 8b61a72 into main Feb 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants