Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 52 additions & 7 deletions src/content/docs/queues/observability/metrics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,64 @@ sidebar:

---

You can view the metrics for a Queue on your account via the [Cloudflare dashboard](https://dash.cloudflare.com). Navigate to **Storage & Databases** > **Queues** > **your Queue** and under the **Metrics** tab you'll be able to view line charts describing the number of messages processed by final outcome, the number of messages in the backlog, and other important indicators.
Queues expose metrics which allow you to measure the queue backlog, consumer concurrency, and message operations.

The metrics displayed in the Cloudflare dashboard charts are all pulled from Cloudflare's GraphQL Analytics API. You can access the metrics programmatically.
The metrics displayed in the [Cloudflare dashboard](https://dash.cloudflare.com/) 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.

The Queues metrics are split across three different nodes under `viewer` > `accounts`. Refer to [Explore the GraphQL schema](/analytics/graphql-api/getting-started/explore-graphql-schema/) to learn how to navigate a GraphQL schema and discover which data are available.
## Metrics
### Backlog
Queues export the below metrics within the `queuesBacklogAdaptiveGroups` dataset.

To learn more about the GraphQL Analytics API, refer to [GraphQL Analytics API](/analytics/graphql-api/).
| Metric | GraphQL Field Name | Description |
| ---------------------- | ------------------------- | ---------------------------------------------------------------|
| Backlog bytes | `bytes` | Average size of the backlog, in bytes |
| Backlog messages | `messages` | Average size of the backlog, in number of messages |

## Write GraphQL queries
The `queuesBacklogAdaptiveGroups` dataset provides the following dimensions for filtering and grouping queries:
* `queueID` - ID of the queue
* `datetime` - Timestamp for when the message was sent
* `date` - Timestamp for when the message was sent, truncated to the start of a day
* `datetimeHour` - Timestamp for when the message was sent, truncated to the start of an hour
* `datetimeMinute` - Timestamp for when the message was sent, truncated to the start of a minute

Examples of how to explore your Queues metrics.
### Consumer concurrency
Queues export the below metrics within the `queueConsumerMetricsAdaptiveGroups` dataset.

### Get average Queue backlog over time period
| Metric | GraphQL Field Name | Description |
| ---------------------- | ------------------------- | --------------------------------------------------------------- |
| Avg. Consumer Concurrency | `concurrency` | Average number of concurrent consumers over the period |

The `queueConsumerMetricsAdaptiveGroups` dataset provides the following dimensions for filtering and grouping queries:
* `queueID` - ID of the queue
* `datetime` - Timestamp for the consumer metrics
* `date` - Timestamp for the consumer metrics, truncated to the start of a day
* `datetimeHour` - Timestamp for the consumer metrics, truncated to the start of an hour
* `datetimeMinute` - Timestamp for the consumer metrics, truncated to the start of a minute

### Message operations
Queues export the below metrics within the `queueMessageOperationsAdaptiveGroups` dataset.

| Metric | GraphQL Field Name | Description |
| ---------------------- | ------------------------- | --------------------------------------------------------------- |
| Total billable operations | `billableOperations` | Sum of billable operations (writes, reads, and deletes) over the time period |
| Total Bytes | `bytes` | Sum of bytes read, written, and deleted from the queue |
| Lag | `lagTime` | Average lag time in milliseconds between when the message was written and the operation to consume the message. |
| Retries | `retryCount` | Average number of retries per message |
| Message Size | `messageSize` | Maximum message size over the specified period |

The `queueMessageOperationsAdaptiveGroups` dataset provides the following dimensions for filtering and grouping queries:
* `queueID` - ID of the queue
* `actionType` - The type of message operation. Can be `WriteMessage`, `ReadMessage` or `DeleteMessage`
* `consumerType` - The queue consumer type. Can be `worker` or `http`. Only applicable for `ReadMessage` and `DeleteMessage` action types
* `outcome` - The outcome of the mesage operation. Only applicable for `DeleteMessage` action types. Can be `success`, `dlq` or `fail`.
* `datetime` - Timestamp for the message operation
* `date` - Timestamp for the message operation, truncated to the start of a day
* `datetimeHour` - Timestamp for the message operation, truncated to the start of an hour
* `datetimeMinute` - Timestamp for the message operation, truncated to the start of a minute

## Example GraphQL Queries

### Get average queue backlog over time period

```graphql
query QueueBacklog($accountTag: string!, $queueId: string!, $datetimeStart: Time!, $datetimeEnd: Time!) {
Expand Down
Loading