Skip to content

Commit a21c2a0

Browse files
committed
wrangler
1 parent 0fc5105 commit a21c2a0

File tree

2 files changed

+190
-11
lines changed

2 files changed

+190
-11
lines changed

src/content/docs/workers/wrangler/commands.mdx

Lines changed: 142 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Wrangler offers a number of commands to manage your Cloudflare Workers.
2828
- [`r2 object`](#r2-object) - Manage Workers R2 objects.
2929
- [`secret`](#secret) - Manage the secret variables for a Worker.
3030
- [`secret:bulk`](#secretbulk) - Manage multiple secret variables for a Worker.
31+
- [`workflows`](#workflows) - Manage and configure Workflows.
3132
- [`tail`](#tail) - Start a session to livestream logs from a deployed Worker.
3233
- [`pages`](#pages) - Configure Cloudflare Pages.
3334
- [`queues`](#queues) - Configure Workers Queues.
@@ -138,10 +139,10 @@ wrangler docs [<COMMAND>]
138139

139140
## `init`
140141

141-
:::note
142+
:::note
142143

143144

144-
The `init` command will be removed in a future version. Please use `npm create cloudflare@latest` instead.
145+
The `init` command will be removed in a future version. Please use `npm create cloudflare@latest` instead.
145146

146147

147148
:::
@@ -1244,6 +1245,145 @@ Finished processing secrets JSON file:
12441245
🚨 1 secrets failed to upload
12451246
```
12461247

1248+
## `workflows`
1249+
1250+
Manage and configure [Workflows](/workflows/).
1251+
1252+
### `list`
1253+
1254+
Lists the registered Workflows for this account.
1255+
1256+
```sh
1257+
wrangler workflows list
1258+
```
1259+
1260+
- `--page` <Type text="number" /> <MetaInfo text="optional" />
1261+
- Show a sepecific page from the listing, can configure page size using "per-page"
1262+
- `--per-page` <Type text="number" /> <MetaInfo text="optional" />
1263+
- Configure the maximum number of workflows to show per page.
1264+
1265+
### `instances`
1266+
1267+
Manage and interact with specific instances of a Workflow.
1268+
1269+
### `instances list`
1270+
1271+
List Workflow instances.
1272+
1273+
```sh
1274+
wrangler workflows instances list <WORKFLOW_NAME> [OPTIONS]
1275+
```
1276+
1277+
- `WORKFLOW_NAME` <Type text="string" /> <MetaInfo text="required" />
1278+
- The name of a registered Workflow.
1279+
1280+
### `instances describe`
1281+
1282+
Describe a specific instance of a Workflow, including its current status, any persisted state, and per-step outputs.
1283+
1284+
```sh
1285+
wrangler workflows instances describe <WORKFLOW_NAME> <ID> [OPTIONS]
1286+
```
1287+
1288+
- `WORKFLOW_NAME` <Type text="string" /> <MetaInfo text="required" />
1289+
- The name of a registered Workflow.
1290+
- `ID` <Type text="string" /> <MetaInfo text="required" />
1291+
- The ID of a Workflow instance. You can optionally provide `latest` to refer to the most recently created instance of a Workflow.
1292+
1293+
```sh
1294+
# Passing `latest` instead of an explicit ID will describe the most recently queued instance
1295+
wrangler workflows instances describe my-workflow latest
1296+
```
1297+
```sh output
1298+
Workflow Name: my-workflow
1299+
Instance Id: 51c73fc8-7fd5-47d9-bd82-9e301506ee72
1300+
Version Id: cedc33a0-11fa-4c26-8a8e-7d28d381a291
1301+
Status: ✅ Completed
1302+
Trigger: 🌎 API
1303+
Queued: 10/16/2024, 2:00:39 PM
1304+
Success: ✅ Yes
1305+
Start: 10/16/2024, 2:00:39 PM
1306+
End: 10/16/2024, 2:01:40 PM
1307+
Duration: 1 minute
1308+
# Remaining output truncated
1309+
```
1310+
1311+
### `instances terminate`
1312+
1313+
Terminate (permanently stop) a Workflow instance.
1314+
1315+
```sh
1316+
wrangler workflows instances terminate <WORKFLOW_NAME> <ID> [OPTIONS]
1317+
```
1318+
1319+
- `WORKFLOW_NAME` <Type text="string" /> <MetaInfo text="required" />
1320+
- The name of a registered Workflow.
1321+
- `ID` <Type text="string" /> <MetaInfo text="required" />
1322+
- The ID of a Workflow instance.
1323+
1324+
### `instances pause`
1325+
1326+
Pause (until resumed) a Workflow instance.
1327+
1328+
```sh
1329+
wrangler workflows instances pause <WORKFLOW_NAME> <ID> [OPTIONS]
1330+
```
1331+
1332+
- `WORKFLOW_NAME` <Type text="string" /> <MetaInfo text="required" />
1333+
- The name of a registered Workflow.
1334+
- `ID` <Type text="string" /> <MetaInfo text="required" />
1335+
- The ID of a Workflow instance.
1336+
1337+
### `instances resume`
1338+
1339+
Resume a paused Workflow instance.
1340+
1341+
```sh
1342+
wrangler workflows instances resume <WORKFLOW_NAME> <ID> [OPTIONS]
1343+
```
1344+
1345+
- `WORKFLOW_NAME` <Type text="string" /> <MetaInfo text="required" />
1346+
- The name of a registered Workflow.
1347+
- `ID` <Type text="string" /> <MetaInfo text="required" />
1348+
- The ID of a Workflow instance.
1349+
1350+
### `describe`
1351+
1352+
```sh
1353+
wrangler workflows describe <WORKFLOW_NAME> [OPTIONS]
1354+
```
1355+
1356+
- `WORKFLOW_NAME` <Type text="string" /> <MetaInfo text="required" />
1357+
- The name of a registered Workflow.
1358+
1359+
### `trigger`
1360+
1361+
Trigger (create) a Workflow instance.
1362+
```sh
1363+
wrangler workflows describe <WORKFLOW_NAME> <PARAMS> [OPTIONS]
1364+
```
1365+
1366+
- `WORKFLOW_NAME` <Type text="string" /> <MetaInfo text="required" />
1367+
- The name of a registered Workflow.
1368+
- `PARAMS` <Type text="string" /> <MetaInfo text="optional" />
1369+
- The parameters to pass to the Workflow as an event. Must be a JSON-encoded string.
1370+
1371+
```sh
1372+
# Pass optional params to the Workflow.
1373+
wrangler workflows instances trigger my-workflow '{"hello":"world"}'
1374+
```
1375+
1376+
### `delete`
1377+
1378+
Delete (unregister) a Workflow.
1379+
1380+
```sh
1381+
wrangler workflows delete <WORKFLOW_NAME> [OPTIONS]
1382+
```
1383+
1384+
- `WORKFLOW_NAME` <Type text="string" /> <MetaInfo text="required" />
1385+
- The name of a registered Workflow.
1386+
12471387
## `tail`
12481388

12491389
Start a session to livestream logs from a deployed Worker.

src/content/docs/workflows/observability/metrics-analytics.mdx

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,63 @@ sidebar:
66

77
---
88

9-
D1 exposes database analytics that allow you to inspect query volume, query latency, and storage size across all and/or each database in your account.
9+
Workflows exposes metrics that allow you to inspect and measure Workflow execution, error rates, steps and total duration across each (and all) of your Workflows.
1010

1111
The metrics displayed in the [Cloudflare dashboard](https://dash.cloudflare.com/) charts are queried from Cloudflare’s [GraphQL Analytics API](/analytics/graphql-api/). You can access the metrics [programmatically](#query-via-the-graphql-api) via GraphQL or HTTP client.
1212

1313
## Metrics
1414

15-
D1 currently exports the below metrics:
15+
Workflows currently exports the below metrics:
1616

1717
| Metric | GraphQL Field Name | Description |
1818
| ---------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
1919
| 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. |
20-
| Write Queries (qps) | `writeQueries` | The number of write queries issued against a database. This is the raw number of write queries, and is not used for billing. |
21-
| Rows read (count) | `rowsRead` | The number of rows read (scanned) across your queries. See [Pricing](/d1/platform/pricing/) for more details on how rows are counted. |
22-
| Rows written (count) | `rowsWritten` | The number of rows written across your queries. |
23-
| Query Response (bytes) | `queryBatchResponseBytes` | The total response size of the serialized query response, including any/all column names, rows and metadata. Reported in bytes. |
24-
| Query Latency (ms) | `queryBatchTimeMs` | The total query response time, including response serialization, on the server-side. Reported in milliseconds. |
25-
| Storage (Bytes) | `databaseSizeBytes` | Maximum size of a database. Reported in bytes. |
2620

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

29-
### Row count
23+
## View metrics in the dashboard
24+
25+
Per-Workflow and instance analytics for Workflows are available in the Cloudflare dashboard. To view current and historical metrics for a database:
26+
27+
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
28+
2. Go to [**Workers & Pages** > **Workflows**](https://dash.cloudflare.com/?to=/:account/workers/workflows).
29+
3. Select a Workflow to view its metrics.
30+
31+
You can optionally select a time window to query. This defaults to the last 24 hours.
32+
33+
## Query via the GraphQL API
34+
35+
You can programmatically query analytics for your Workflows via the [GraphQL Analytics API](/analytics/graphql-api/). This API queries the same datasets as the Cloudflare dashboard, and supports GraphQL [introspection](/analytics/graphql-api/features/discovery/introspection/).
36+
37+
Workflows GraphQL datasets require an `accountTag` filter with your Cloudflare account ID and includes the `workflowsAdaptive` and `workflowsAdaptiveGroups` datasets.
38+
39+
### Examples
40+
41+
To query the sum of `readQueries`, `writeQueries` for a given `$databaseId`, grouping by `databaseId` and `date`:
42+
43+
```graphql
44+
query {
45+
viewer {
46+
accounts(filter: { accountTag: $accountId }) {
47+
d1AnalyticsAdaptiveGroups(
48+
limit: 10000
49+
filter: {
50+
date_geq: $startDate
51+
date_leq: $endDate
52+
databaseId: $databaseId
53+
}
54+
orderBy: [date_DESC]
55+
) {
56+
sum {
57+
readQueries
58+
writeQueries
59+
}
60+
dimensions {
61+
date
62+
databaseId
63+
}
64+
}
65+
}
66+
}
67+
}
68+
```

0 commit comments

Comments
 (0)