Metrics and analytics
KV exposes analytics that allow you to inspect requests and storage across all namespaces in your account.
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.
KV currently exposes the below metrics:
Dataset | GraphQL Dataset Name | Description |
---|---|---|
Operations | kvOperationsAdaptiveGroups | This dataset consists of the operations made to your KV namespaces. |
Storage | kvStorageAdaptiveGroups | This dataset consists of the storage details of your KV namespaces. |
Metrics can be queried (and are retained) for the past 31 days.
Per-namespace analytics for KV are available in the Cloudflare dashboard. To view current and historical metrics for a database:
- Log in to the Cloudflare dashboard ↗ and select your account.
- Go to Workers & Pages > KV ↗.
- Select an existing namespace.
- Select the Metrics tab.
You can optionally select a time window to query. This defaults to the last 24 hours.
You can programmatically query analytics for your KV namespaces via the GraphQL Analytics API. This API queries the same datasets as the Cloudflare dashboard, and supports GraphQL introspection.
To get started using the GraphQL Analytics API, follow the documentation to setup Authentication for the GraphQL Analytics API.
To use the GraphQL API to retrieve KV’s datasets, you must provide the accountTag
filter with your Cloudflare Account ID. The GraphQL datasets for KV include:
kvOperationsAdaptiveGroups
kvStorageAdaptiveGroups
The following are common GraphQL queries that you can use to retrieve information about KV analytics. These queries make use of variables $accountTag
, $date_geq
, $date_leq
, and $namespaceId
, which should be set as GraphQL variables or replaced in line. These variables should look similar to these:
To query the sum of read, write, delete, and list operations for a given namespaceId
and for a given date range (date_geq
and date_leq
), grouped by date
and actionType
:
To query the distribution of the latency for read operations for a given namespaceId
within a given date range (date_geq
, date_leq
):
To query your account-wide read, write, delete, and list operations across all KV namespaces:
To query the storage details (keyCount
and byteCount
) of a KV namespace for every day of a given date range: