// Guides2026-06-235 min read

How to Check Your Exact Cloudflare Analytics Retention Limits

“How long does Cloudflare keep my analytics?” sounds like it should have a one-line answer.

It doesn’t. Cloudflare’s own docs say that higher plans “can query over broader historical intervals” — but the exact limit depends on which dataset you query and which plan the zone is on. There is no single number.

The good news: you don’t have to guess. Cloudflare exposes the exact limits for your account through the API.

Why there’s no single retention number

Everything you see in the Cloudflare dashboard is built on the GraphQL Analytics API, which is split into dozens of datasets:

  • httpRequests1dGroups — daily traffic rollups
  • httpRequestsAdaptiveGroups — detailed, sampled HTTP traffic
  • firewallEventsAdaptive — individual security events

Each dataset has its own limits, and those limits change with your plan. A daily rollup can reach much further back than per-request security events on the same zone.

The one limit Cloudflare does publish: Security Events are kept for up to 24 hours on Free and Pro, 3 days on Business, and 30 days on Enterprise. See Cloudflare Security Events retention by plan for what that means in practice.

Two more products have fixed, documented limits:

  • Workers Analytics Engine stores data for three months.
  • Network Analytics (Magic Transit, Spectrum, Cloudflare WAN) keeps 16 weeks. Data older than eight weeks may have lower resolution when you query narrow time frames.

The settings node: your real limits, per dataset

The GraphQL API has a settings node that reports, for every dataset:

Field What it tells you
enabled Whether your plan can query this dataset at all
notOlderThan How far back a query can read, in seconds
maxDuration The widest time range allowed in a single query, in seconds
maxPageSize Maximum rows returned per query
availableFields Which fields your plan can use

notOlderThan is the number you care about. It is your retention limit for that dataset.

Step 1: Create a read-only API token

In the Cloudflare dashboard, go to My Profile → API Tokens → Create Token and grant Analytics: Read on the zone you want to check. Nothing else is needed.

Export it along with your zone ID (shown on the zone’s Overview page):

export CF_API_TOKEN="your-token"
export ZONE_ID="your-zone-id"

Step 2: Query the settings node

curl -s https://api.cloudflare.com/client/v4/graphql \
  -H "Authorization: Bearer $CF_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{
    "query": "query ($zoneTag: string) { viewer { zones(filter: {zoneTag: $zoneTag}) { settings { httpRequests1dGroups { enabled notOlderThan maxDuration } httpRequestsAdaptiveGroups { enabled notOlderThan maxDuration } firewallEventsAdaptive { enabled notOlderThan maxDuration } } } } }",
    "variables": { "zoneTag": "'"$ZONE_ID"'" }
  }' | jq '.data.viewer.zones[0].settings'

Step 3: Convert seconds to days

The raw numbers are in seconds. Pipe the settings through jq to make them readable:

... | jq '.data.viewer.zones[0].settings
  | map_values(if . == null then null else {
      enabled,
      retentionDays: (.notOlderThan / 86400),
      maxRangeDays: (.maxDuration / 86400)
    } end)'

For reference, Cloudflare’s documentation shows an example firewallEventsAdaptive result of notOlderThan: 2678400 (31 days) and maxDuration: 259200 (3 days). That means data goes back 31 days, but each query can only cover a 3-day window.

How to read the results

  • enabled: false — your plan can’t query that dataset. Upgrading is the only way in.
  • Small notOlderThan — this is the edge of your history. Anything older is gone for good.
  • maxDuration smaller than notOlderThan — you can reach old data, but you have to page through it in windows. Plan for that in any export script.

Run the check on every zone you care about. Zones on different plans in the same account get different limits.

What to do if the window is too short

If notOlderThan is shorter than the history you need, you have two options:

  1. Upgrade your plan. Enterprise gets longer windows and raw logs through Logpush.
  2. Copy the data out before it expires. Snapshot the datasets on a schedule and store them yourself — see how to archive Cloudflare analytics to R2 with a Worker.

For the bigger picture on plans and workarounds, start with how long Cloudflare keeps analytics data.

Skip the scripts

MetricKeeper runs this archiving for you. Connect a read-only API token, pick your zones, and it snapshots your Cloudflare analytics on a schedule so the history stays searchable after Cloudflare’s window closes.

Get Early Access →

Sources