Skip to content

Metrics and analytics

Workflows expose metrics that allow you to inspect and measure Workflow execution, error rates, steps, and total duration across each (and all) of your Workflows.

The metrics displayed in the Cloudflare dashboard charts are queried from Cloudflare’s GraphQL Analytics API. You can access the metrics programmatically via GraphQL or HTTP client.

Metrics

Workflows currently export the below metrics within the workflowsAdaptiveGroups GraphQL dataset.

MetricGraphQL Field NameDescription
Read Queries (qps)readQueriesThe number of read queries issued against a database. This is the raw number of read queries, and is not used for billing.

Metrics can be queried (and are retained) for the past 31 days.

Labels and dimensions

The workflowsAdaptiveGroups dataset provides the following dimensions for filtering and grouping query results:

  • workflowName - Workflow name - e.g. my-workflow
  • instanceId - Instance ID
  • stepName - Step name
  • eventType - Event type (see event types)
  • stepCount - Step number within a given instance
  • date - The date when the Workflow was triggered
  • datetimeFifteenMinutes - The date and time truncated to fifteen minutes
  • datetimeFiveMinutes - The date and time truncated to five minutes
  • datetimeHour - The date and time truncated to the hour
  • datetimeMinute - The date and time truncated to the minute

Event types

The eventType metric allows you to filter (or groupBy) Workflows and steps based on their last observed status.

The possible values for eventType are documented below:

Workflows-level status labels

  • WORKFLOW_QUEUED - the Workflow is queued, but not currently running. This can happen when you are at the concurrency limit and new instances are waiting for currently running instances to complete.
  • WORKFLOW_START - the Workflow has started and is running.
  • WORKFLOW_SUCCESS - the Workflow finished without errors.
  • WORKFLOW_FAILURE - the Workflow failed due to errors (exhausting retries, errors thrown, etc).
  • WORKFLOW_TERMINATED - the Workflow was explicitly terminated.

Step-level status labels

  • STEP_START - the step has started and is running.
  • STEP_SUCCESS - the step finished without errors.
  • STEP_FAILURE - the step failed due to an error.
  • SLEEP_START - the step is sleeping.
  • SLEEP_COMPLETE - the step last finished sleeping.
  • ATTEMPT_START - a step is retrying.
  • ATTEMPT_SUCCESS - the retry succeeded.
  • ATTEMPT_FAILURE - the retry attempt failed.

View metrics in the dashboard

Per-Workflow and instance analytics for Workflows are available in the Cloudflare dashboard. To view current and historical metrics for a database:

  1. Log in to the Cloudflare dashboard and select your account.
  2. Go to Workers & Pages > Workflows.
  3. Select a Workflow to view its metrics.

You can optionally select a time window to query. This defaults to the last 24 hours.

Query via the GraphQL API

You can programmatically query analytics for your Workflows via the GraphQL Analytics API. This API queries the same datasets as the Cloudflare dashboard, and supports GraphQL introspection.

Workflows GraphQL datasets require an accountTag filter with your Cloudflare account ID, and includes the workflowsAdaptiveGroups dataset.

Examples

To query the count (number of workflow invocations) and sum of wallTime for a given $workflowName between $datetimeStart and $datetimeEnd, grouping by date:

{
viewer {
accounts(filter: { accountTag: $accountTag }) {
wallTime: workflowsAdaptiveGroups(
limit: 10000
filter: {
datetimeHour_geq: $datetimeStart,
datetimeHour_leq: $datetimeEnd,
workflowName: $workflowName
}
orderBy: [count_DESC]
) {
count
sum {
wallTime
}
dimensions {
date: datetimeHour
}
}
}
}
}

Here we are doing the same for wallTime, instanceRuns and stepCount in the same query:

{
viewer {
accounts(filter: { accountTag: $accountTag }) {
instanceRuns: workflowsAdaptiveGroups(
limit: 10000
filter: {
datetimeHour_geq: $datetimeStart
datetimeHour_leq: $datetimeEnd
workflowName: $workflowName
eventType: "WORKFLOW_START"
}
orderBy: [count_DESC]
) {
count
dimensions {
date: datetimeHour
}
}
stepCount: workflowsAdaptiveGroups(
limit: 10000
filter: {
datetimeHour_geq: $datetimeStart
datetimeHour_leq: $datetimeEnd
workflowName: $workflowName
eventType: "STEP_START"
}
orderBy: [count_DESC]
) {
count
dimensions {
date: datetimeHour
}
}
wallTime: workflowsAdaptiveGroups(
limit: 10000
filter: {
datetimeHour_geq: $datetimeStart
datetimeHour_leq: $datetimeEnd
workflowName: $workflowName
}
orderBy: [count_DESC]
) {
count
sum {
wallTime
}
dimensions {
date: datetimeHour
}
}
}
}
}

Here lets query workflowsAdaptive for raw data about $instanceId between $datetimeStart and $datetimeEnd:

{
viewer {
accounts(filter: { accountTag: $accountTag }) {
workflowsAdaptive(
limit: 100
filter: {
datetime_geq: $datetimeStart
datetime_leq: $datetimeEnd
instanceId: $instanceId
}
orderBy: [datetime_ASC]
) {
datetime
eventType
workflowName
instanceId
stepName
stepCount
wallTime
}
}
}
}

GraphQL query variables

Example values for the query variables:

{
"accountTag": "fedfa729a5b0ecfd623bca1f9000f0a22",
"datetimeStart": "2024-10-20T00:00:00Z",
"datetimeEnd": "2024-10-29T00:00:00Z",
"workflowName": "shoppingCart",
"instanceId": "ecc48200-11c4-22a3-b05f-88a3c1c1db81"
}