INTEGRITY Cloudflare Docs

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.

Metric GraphQL Field Name Description
Read Queries (qps) readQueries The 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:

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

Step-level status labels

Rollback events let you distinguish forward execution failures from compensation failures when you are querying Workflow health or debugging instance timelines.

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. In the Cloudflare dashboard, go to the Workflows page.

    Go to Workflows ↗
  2. 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:

query WorkflowInvocationsExample(
	$accountTag: string!
	$datetimeStart: Time
	$datetimeEnd: Time
	$workflowName: string
) {
	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:

query WorkflowInvocationsExample2(
	$accountTag: string!
	$datetimeStart: Time
	$datetimeEnd: Time
	$workflowName: string
) {
	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: "WORKFLOW_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:

query WorkflowsAdaptiveExample(
	$accountTag: string!
	$datetimeStart: Time
	$datetimeEnd: Time
	$instanceId: string
) {
	viewer {
		accounts(filter: { accountTag: $accountTag }) {
			workflowsAdaptive(
				limit: 100
				filter: {
					datetime_geq: $datetimeStart
					datetime_leq: $datetimeEnd
					instanceId: $instanceId
				}
				orderBy: [datetime_ASC]
			) {
				datetime
				eventType
				workflowName
				instanceId
				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"
}