All skills
Skillintermediate

Cloudflare GraphQL Analytics API

Query analytics data across all Cloudflare products via a single GraphQL endpoint. Covers HTTP requests, Workers metrics, DNS, Firewall events, Network Analytics, and 70+ other datasets.

Claude Code Knowledge Pack7/10/2026

Overview

Cloudflare GraphQL Analytics API

Query analytics data across all Cloudflare products via a single GraphQL endpoint. Covers HTTP requests, Workers metrics, DNS, Firewall events, Network Analytics, and 70+ other datasets.

Overview

  • Single endpoint for all analytics: https://api.cloudflare.com/client/v4/graphql
  • 1,400+ schema types spanning every Cloudflare product
  • Two scopes: zone-level (per-domain) and account-level (cross-domain)
  • Adaptive sampling on high-traffic datasets with confidence intervals
  • No mutations - read-only analytics (the Mutation type is a stub)
  • Cost-based rate limiting - default 300 queries per 5 minutes per user (max 320, varies by query cost)

Quick Decision Tree

Need analytics data from Cloudflare?
├─ HTTP traffic (requests, bandwidth, cache) → httpRequestsAdaptiveGroups (zone or account)
├─ Workers performance (CPU, wall time, errors) → workersInvocationsAdaptive (account)
├─ Firewall/WAF events → firewallEventsAdaptive / firewallEventsAdaptiveGroups (zone or account)
├─ DNS query analytics → dnsAnalyticsAdaptive / dnsAnalyticsAdaptiveGroups (zone or account)
├─ Network layer (DDoS, Magic Transit) → *NetworkAnalyticsAdaptiveGroups (account)
├─ Storage (R2, KV, D1, DO) → r2OperationsAdaptiveGroups / kvOperationsAdaptiveGroups / etc. (account)
├─ AI (Workers AI, AI Gateway) → aiInferenceAdaptive / aiGatewayRequestsAdaptiveGroups (account)
├─ Load Balancing → loadBalancingRequestsAdaptiveGroups (zone)
├─ Custom high-cardinality metrics → Workers Analytics Engine (see ../analytics-engine/)
└─ Need raw logs, not aggregates → Logpush (see Cloudflare docs)

Core Concepts

ConceptDescription
EndpointPOST https://api.cloudflare.com/client/v4/graphql
Explorergraphql.cloudflare.com - interactive query builder
ViewerRoot query object: viewer { zones(...) { ... } } or viewer { accounts(...) { ... } }
Dataset (Node)A queryable table under a zone or account (e.g., httpRequestsAdaptiveGroups)
DimensionsFields to group by (time buckets, country, status code, script name, etc.)
MetricsAggregation fields: count, sum { ... }, avg { ... }, quantiles { ... }, ratio { ... }
FilterInput object constraining results by time range, dimensions, etc.
LimitMaximum rows returned per dataset node (required, max varies by dataset)
OrderByEnum-based sorting: [field_ASC] or [field_DESC]
Adaptive SamplingNodes with Adaptive in the name use ABR sampling; results are statistically representative

Query Structure

Every query follows this pattern:

{
  viewer {
    # Zone-scoped
    zones(filter: { zoneTag: "ZONE_ID" }) {
      datasetName(
        filter: { datetime_gt: "...", datetime_lt: "..." }
        limit: 1000
        orderBy: [datetimeFiveMinutes_DESC]
      ) {
        count
        dimensions { ... }
        sum { ... }
      }
    }
    # Account-scoped
    accounts(filter: { accountTag: "ACCOUNT_ID" }) {
      datasetName(filter: { ... }, limit: 100) {
        count
        dimensions { ... }
        sum { ... }
      }
    }
  }
}

Dataset Naming Convention

Dataset names follow a consistent pattern visible in the schema:

PatternMeaningExample
*AdaptiveRaw rows with adaptive sampling; some (e.g., workersInvocationsAdaptive) also support aggregation fields (sum, quantiles, avg)httpRequestsAdaptive, workersInvocationsAdaptive
*AdaptiveGroupsAggregated data with adaptive samplinghttpRequestsAdaptiveGroups
*1hGroupsHourly rollups (pre-aggregated)httpRequests1hGroups
*1dGroupsDaily rollups (pre-aggregated)httpRequests1dGroups
*1mGroupsMinutely rollupshttpRequests1mGroups
Zone* prefixZone-scoped datasetZoneHttpRequestsAdaptiveGroups
Account* prefixAccount-scoped datasetAccountWorkersInvocationsAdaptive

Prefer *AdaptiveGroups nodes for most use cases - they support flexible time grouping via dimension fields (datetimeFiveMinutes, datetimeHour, etc.) and are the most commonly used.

Key Datasets by Product

Zone-Scoped (per-domain)

DatasetDescription
httpRequestsAdaptiveGroupsHTTP traffic: requests, bytes, cache status, bot scores, WAF scores
httpRequests1hGroups / 1dGroups / 1mGroupsPre-aggregated HTTP rollups (hourly/daily/minutely)
firewallEventsAdaptiveGroupsWAF, rate limiting, bot management, firewall rule events
dnsAnalyticsAdaptiveGroupsDNS query volumes, response codes, query types
loadBalancingRequestsAdaptiveGroupsLoad Balancer origin request metrics
pageShieldReportsAdaptiveGroupsPage Shield CSP reports

Account-Scoped (cross-domain)

DatasetDescription
workersInvocationsAdaptiveWorkers: requests, errors, CPU time, wall time, subrequests
durableObjectsInvocationsAdaptiveGroupsDO invocations
durableObjectsStorageGroups / durableObjectsPeriodicGroupsDO storage and periodic metrics
d1AnalyticsAdaptiveGroups / d1QueriesAdaptiveGroupsD1 database analytics
r2OperationsAdaptiveGroups / r2StorageAdaptiveGroupsR2 operations and storage
kvOperationsAdaptiveGroups / kvStorageAdaptiveGroupsKV operations and storage
aiInferenceAdaptiveGroupsWorkers AI inference metrics
aiGatewayRequestsAdaptiveGroupsAI Gateway request analytics
pagesFunctionsInvocationsAdaptiveGroupsPages Functions metrics
magicTransitNetworkAnalyticsAdaptiveGroupsMagic Transit packet/byte analytics
spectrumNetworkAnalyticsAdaptiveGroupsSpectrum TCP/UDP analytics
gatewayL7RequestsAdaptiveGroupsZero Trust Gateway HTTP metrics
gatewayResolverQueriesAdaptiveGroupsZero Trust Gateway DNS metrics

Reading Order

TaskStart HereThen Read
First queryconfiguration.md (auth) -> this README (structure)api.md
Build a dashboardpatterns.md (time-series, top-N)api.md (aggregation fields)
Debug query issuesgotchas.mdapi.md (filtering)
Understand samplinggotchas.md (sampling section)api.md (confidence intervals)
Product-specific metricspatterns.md (per-product examples)api.md (dataset reference)

In This Reference

  • api.md - Query structure, aggregation fields (sum/avg/quantiles/count), filtering operators, dimensions, dataset details
  • configuration.md - Authentication, API tokens, client setup (curl, JS, Python), introspection
  • patterns.md - Common queries: time-series, top-N, Workers metrics, HTTP analytics, firewall events, multi-zone
  • gotchas.md - Rate limits, sampling caveats, query cost, common errors, plan-based limits

See Also