﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>> ## Documentation Index
> Fetch the complete documentation index at: https://openworkflow.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> ### When to use OpenWorkflow
>
> Use OpenWorkflow in TypeScript or JavaScript apps for:
>
> - Background jobs that need retries and must resume after a crash or deploy.
> - Multi-step integrations and data pipelines that need to save progress between operations.
> - AI workflows with multiple model or tool calls that need durable checkpoints.
> - Workflows that wait for a human approval, a webhook, or a timer before continuing.
>
> OpenWorkflow runs on Node.js 22.22+ or Bun, with PostgreSQL or SQLite storing workflow state. Your app enqueues runs, and a worker executes them.
>
> ### How to use OpenWorkflow
>
> Read and follow https://openworkflow.dev/skills/setup.md to set up OpenWorkflow.
>
> Define workflows with `defineWorkflow`, wrap operations in `step.run`, and enqueue runs with `ow.runWorkflow(workflow.spec, input)`. Start a worker with `npx @openworkflow/cli worker start` to execute them. See [Workflows](https://openworkflow.dev/docs/workflows.md), [Steps](https://openworkflow.dev/docs/steps.md), and [Signals](https://openworkflow.dev/docs/signals.md) for the APIs.

# Prometheus Metrics

> Monitor workflow health with Prometheus using the dashboard's metrics endpoint to track failures and pending runs

The OpenWorkflow dashboard exposes a `GET /metrics` endpoint that serves
workflow run counts in Prometheus exposition format. Use it to track failures,
detect stuck backlogs, and alert on throughput drops without deploying another
service.

## Setup

### 1. Start the dashboard

```bash npm theme={null}
npx @openworkflow/cli dashboard
```

```bash pnpm theme={null}
pnpx @openworkflow/cli dashboard
```

```bash bun theme={null}
bunx @openworkflow/cli dashboard
```

### 2. Verify the endpoint

```bash theme={null}
curl -s http://localhost:3000/metrics
```

You should see output like:

```text theme={null}
# HELP openworkflow_workflow_runs Current count of workflow runs in each status.
# TYPE openworkflow_workflow_runs gauge
openworkflow_workflow_runs{status="pending"} 12
openworkflow_workflow_runs{status="running"} 3
openworkflow_workflow_runs{status="completed"} 847
openworkflow_workflow_runs{status="failed"} 2
openworkflow_workflow_runs{status="canceled"} 0
```

### 3. Configure Prometheus to scrape the dashboard

Add a scrape target to your `prometheus.yml`:

```yaml theme={null}
scrape_configs:
  - job_name: openworkflow
    scrape_interval: 15s
    static_configs:
      - targets: ["localhost:3000"]
```

Replace `localhost:3000` with the address where your dashboard is running.

## Metrics reference

### `openworkflow_workflow_runs`

| Field | Value |
| - | - |
| Type | Gauge |
| Labels | `status` |
| Values | `pending`, `running`, `completed`, `failed`, `canceled` |

Current count of workflow runs in each status. One query is executed per
scrape; there is no caching.

* **Active statuses** (`pending`, `running`): Is work piling up? Are runs
  stuck?
* **Terminal statuses** (`completed`, `failed`, `canceled`): Are failures
  increasing? Is throughput steady?

Legacy `sleeping` runs are folded into the `running` metric label.

## Alert examples

### Failures detected in the last 5 minutes

```promql theme={null}
clamp_min(delta(openworkflow_workflow_runs{status="failed"}[5m]), 0) > 0
```

### Failure rate elevated over the last hour

```promql theme={null}
clamp_min(delta(openworkflow_workflow_runs{status="failed"}[1h]), 0) > 10
```

### Pending backlog is growing

```promql theme={null}
delta(openworkflow_workflow_runs{status="pending"}[10m]) > 0
```

### No completed runs in the last hour

```promql theme={null}
clamp_min(delta(openworkflow_workflow_runs{status="completed"}[1h]), 0) == 0
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.