---
name: cloudflare-workers-errors-and-usage
description: "Every morning: requests, error rate and CPU time per Cloudflare Worker for the last 24 hours, against the same day last week, with the top exceptions. Use when the user asks for this, or when it runs on a schedule."
---

# Cloudflare Workers errors and usage

Every morning: requests, error rate and CPU time per Cloudflare Worker for the last 24 hours, against the same day last week, with the top exceptions.

The Workers dashboard shows one script at a time, and an error rate creeping from 0.2% to 2% looks like a flat line at the scale of the request chart. Exceptions that only hit one route stay invisible until a customer writes in.

The agent queries the GraphQL Analytics API for every Worker on the account, compares the last 24 hours with the same window a week earlier, and pulls the most frequent exception messages from Workers Logs. The card names the Worker that changed and the error behind it.

## Two ways to get the data

Use the API or MCP route when you have an MCP server, a CLI or an API token for the app. Otherwise, if you can drive a browser the user is signed in to (Claude in Chrome, a Playwright or Chrome DevTools MCP server), use the browser route. Say which one you used.

## Route A: API or MCP server

### What you need

- A Cloudflare API token with Account Analytics read access (and Workers Observability read access for the log query) in `CLOUDFLARE_API_TOKEN`, plus the account ID.
- Or the Cloudflare API MCP server at `https://mcp.cloudflare.com/mcp`, which can run the same GraphQL and REST calls.

If something is missing, say what and stop; do not invent numbers.

### Steps

1. **Query Workers metrics** (Cloudflare): `POST https://api.cloudflare.com/client/v4/graphql` with `viewer { accounts(filter: {accountTag: $account}) { workersInvocationsAdaptive(limit: 1000, filter: {datetime_geq: $start, datetime_leq: $end}) { sum { requests errors subrequests } quantiles { cpuTimeP50 cpuTimeP99 } dimensions { scriptName status } } } }`. Run it for the last 24 hours and for the same 24 hours a week earlier.
2. **Compute per Worker**: Sum requests and errors per `scriptName` across `status` values, then error rate = errors / requests. CPU quantiles come back in microseconds; show milliseconds. Flag a Worker whose error rate is above 1% or at least double last week's.
3. **Pull the top exceptions** (Cloudflare): If Workers Logs is on (`[observability] enabled = true` in the Wrangler config), call `POST /accounts/{account_id}/workers/observability/telemetry/keys` to see the available fields, then `.../telemetry/query` for the last 24 hours, filtered to errors and grouped by message. Logs are kept for 7 days.
4. **Report**: Totals for the account, then one row per Worker with requests, error rate, CPU p99 and the change against last week. Under the flagged Worker, list its three most frequent exception messages with counts.

## Route B: the browser

### What you need

- Signed in to the Cloudflare dashboard with a member role that can view Workers analytics and logs for the account (Administrator Read Only is enough).

If something is missing, say what and stop; do not invent numbers.

### Steps

Start at https://dash.cloudflare.com/?to=/:account/workers-and-pages. The user is signed in already; never type passwords or codes, and ask if a sign-in page appears.

1. **Open Workers & Pages for the account**: The URL asks for the account when you have more than one. The overview lists every Worker with its recent request and error counts; note the names, since each one is opened in turn.
2. **Read each Worker's Metrics tab for the last 24 hours**: Open a Worker and its **Metrics** tab. Set the time range to **Previous 24 hours** and read the **Requests** total, the **Errors** total and the **CPU time** chart's P50 and P99. Error rate is errors divided by requests; the chart shows CPU in milliseconds already.
3. **Compare with the same day last week**: Switch the range to **Previous 7 days** and hover the same 24-hour window seven days earlier to read requests and errors there. Flag a Worker whose error rate is above 1% now or at least double what it was a week ago.
4. **Pull the top exceptions from Workers Logs**: For a flagged Worker open its **Logs** tab (it only has data when observability is enabled for that Worker). Set the range to the last 24 hours, filter on `$metadata.error` or the error level, and read the three most frequent messages with their counts from the grouped view.
5. **Report**: Account totals, then one row per Worker with requests, error rate, CPU P99 and the change against last week, and the three top exception messages under each flagged Worker.

Note: The dashboard shows one Worker at a time, so with ten or more Workers this route is slow and the GraphQL route is the better one. Week-over-week numbers read off a hovered chart are approximate. The Logs tab only exists for Workers with observability enabled, and it keeps 7 days.

## The report

- **Account totals**: requests, errors and error rate for the last 24 hours, against the same window last week.
- **Per Worker**: requests, error rate, CPU p50 and p99, and the weekly change.
- **Top exceptions** for any flagged Worker, with counts.
- One line on where to look first.

## Post it to Briefkin

When `BRIEFKIN_TOKEN` is set, or `~/.config/briefkin/env` exists (the installer from https://briefkin.dev/docs writes it), also send the result to the user's Briefkin board as one card. Keep the `item_key` the same on every run so the card updates in place, use a new `event_id` per run, and put today's real numbers in place of the example ones. If the request fails, say so once and carry on.

```bash
[ -n "${BRIEFKIN_TOKEN:-}" ] || . ~/.config/briefkin/env
curl -sS -X POST "${BRIEFKIN_URL:-https://briefkin.dev}/v1/events" \
  -H "authorization: Bearer $BRIEFKIN_TOKEN" \
  -H "content-type: application/json" \
  -d @- <<'JSON'
{
  "v": 1,
  "event_id": "cloudflare-workers-errors-and-usage/<date of this run, e.g. 2026-10-16>",
  "item_key": "cloudflare-workers-errors-and-usage",
  "project": "acme",
  "source": "Cloudflare Workers errors and usage skill",
  "kind": "update",
  "title": "api-gateway error rate up to 2.4% since yesterday",
  "summary": "**1.9M** requests across 4 Workers in the last 24 hours. **api-gateway** errors rose from 0.3% to **2.4%**, mostly one exception.",
  "widget": [
    {
      "type": "Table",
      "props": {
        "columns": [
          "Worker",
          "Requests",
          "Error rate",
          "CPU p99",
          "vs last week"
        ],
        "align": [
          "left",
          "right",
          "right",
          "right",
          "left"
        ],
        "rows": [
          [
            "api-gateway",
            "1,284,000",
            "2.4%",
            "18.2 ms",
            "errors up from 0.3%"
          ],
          [
            "image-resizer",
            "412,500",
            "0.1%",
            "41.0 ms",
            "flat"
          ],
          [
            "auth-edge",
            "168,300",
            "0.2%",
            "3.1 ms",
            "requests +12%"
          ],
          [
            "cron-sync",
            "1,440",
            "0.0%",
            "96.4 ms",
            "flat"
          ]
        ]
      }
    },
    {
      "type": "Log",
      "props": {
        "lines": [
          {
            "text": "TypeError: Cannot read properties of undefined (reading 'tenantId')  x 27,410",
            "level": "error"
          },
          {
            "text": "Error: upstream fetch to origin timed out  x 2,960",
            "level": "warn"
          },
          {
            "text": "Error: KV GET failed: key too long  x 446",
            "level": "warn"
          }
        ]
      }
    },
    {
      "type": "Callout",
      "props": {
        "text": "The tenantId errors start at 21:40, right after a deploy of api-gateway. Check requests without an X-Tenant header first.",
        "tone": "warn"
      }
    }
  ]
}
JSON
```

Widgets come from the Briefkin catalog (https://briefkin.dev/v1/catalog). Without a token, just give the user the report.

## Run it on a schedule

Suggested: Every day at 8:00 (`0 8 * * *`). From cron, with the agent signed in on that machine:

```bash
0 8 * * * claude -p "Run the cloudflare-workers-errors-and-usage skill"
# Codex: codex exec, Gemini CLI: gemini -p, Copilot CLI: copilot -p, OpenCode: opencode run
```

Or use the agent's own scheduler (Claude Code routines, Codex automations, Claude or ChatGPT scheduled tasks): https://briefkin.dev/skills/cloudflare-workers-errors-and-usage#schedule

Source: https://briefkin.dev/skills/cloudflare-workers-errors-and-usage
