📌 Part of Blueprint: Production Self-Hosted Infrastructure → L2: Edge Gateway, Runtime & Identity

Rebuilding 786 Requests From Cloudflare GraphQL After Docker Log Rotation

· 5 min read · Case Studies cloudflaregraphqlincident-responseobservabilitygiteaforensics

The Gap Was Created by Rotation, Not by a Missing Log

The incident window was 2026-12-03, 07:28:48Z to 10:25:13Z. By the time I opened the origin, the Gitea container’s Docker log had already rotated: docker logs --since 720h returned the current file, not the incident morning. The only surviving record was Cloudflare’s 30-day GraphQL dataset, whose 767 grouped rows expanded to 786 requests, including 38 writes.

The origin was a self-hosted Gitea container on the infrastructure I manage. It used Docker’s json-file driver with a 50 MB rotation cap. The current file no longer contained the incident window; it had rolled over since the event, so the morning was gone. At the time there was no archive, no remote sink and no per-request trace.

The edge had a different record. Every request to the public hostname passed through Cloudflare, and Cloudflare’s GraphQL Analytics API exposes httpRequestsAdaptiveGroups for 30 days. That dataset was the only surviving record with request-level dimensions.

The first mistake would have been to call it a request log. It is not. It is an aggregate table: one row per unique combination of the dimensions in the query, with a count column. A query that selects datetime, method, path, status and user agent returns 767 rows for this window. Those rows represent 786 requests. Reading the row count as the request count understates the event by 19; reading each row as one request loses every repeat.

The Query Had to Return Dimensions, Not Just a Total

The useful query selected the smallest set of dimensions that could answer three questions: when did the activity start, what did it touch, and which requests changed state. A representative query shape, with the pagination and retry wrapper omitted:

query Requests($zone: String!, $from: Time!, $to: Time!, $ip: String!) {
  viewer {
    zones(filter: { zoneTag: $zone }) {
      httpRequestsAdaptiveGroups(
        limit: 10000
        filter: { datetime_geq: $from, datetime_leq: $to, clientIP: $ip }
        orderBy: [datetime_ASC]
      ) {
        count
        dimensions {
          datetime
          clientRequestHTTPMethodName
          clientRequestPath
          edgeResponseStatus
          userAgent
        }
      }
    }
  }
}

The variables were the zone tag, the UTC boundaries and the source address. I ran the query once per zone; a zone is one Cloudflare configuration unit. Eight zones were in scope; the relevant zone returned rows and the other seven returned none. A second address returned zero rows across all eight zones. That verified the clientIP filter was applied and the second address had no activity there; it did not prove the zone selection was correct.

I then expanded each GraphQL group into count CSV rows, preserving the group dimensions:

rows = []
for group in groups:
    dims = group["dimensions"]
    rows.extend([dims] * group["count"])

That produced the 786-row timeline. Any group with count > 1 collapses multiple requests into one row; skipping the expansion undercounts write methods just as it undercounts total traffic.

The grouped view also exposes what the dataset cannot answer. There is no Ray ID per request. A Ray ID is Cloudflare’s per-request trace identifier; without it, two requests with the same method, path, status, user agent and second-resolution timestamp collapse into one row with count: 2. There is no request body, no response body and no authentication result. The edge can prove that a request arrived and what status the edge returned; it cannot prove which credential was accepted at the origin.

The Timeline the Export Supported

The expanded export produced a clean sequence:

MeasurementValue
First request2026-12-03 07:28:48Z
Last request2026-12-03 10:25:13Z
Duration2 h 56 min 25 s
Request groups767
Requests after expansion786
Write requests38
POST / PUT / DELETE22 / 12 / 4
First write2026-12-03 08:27:55Z
Last write2026-12-03 10:24:34Z
Private repositories in paths22
Files referenced in paths47

The write rows were the part that mattered. Filtering the method column separated reads from state-changing writes. The 22 private repository names appeared in request paths, not in a clone record, so the export could prove that the paths were addressed but not that every repository was fully read.

I kept that distinction in the incident notes. A request proves an attempt; even a 200 status only proves the edge returned a response; neither proves what the origin served. The origin’s own access log would have closed that gap, and it was the record that had already rotated away.

What the Edge Cannot Replace

Three limits are worth writing down before the next incident:

The operational fix is not a better GraphQL query. The change that closes this gap is a second copy of the origin log: Gitea’s access log goes to a remote sink, with retention set to at least 45 days, longer than the edge dataset. The edge export is the fallback, not the primary record.

The Result

The Cloudflare export turned a rotated-away log into a 786-request timeline covering the full incident window. Expanding 767 groups preserved the repeats; filtering the method column isolated 38 writes; grouping the path column produced 22 private repository paths and 47 file paths. The second address returned zero rows in all eight zones; that confirmed the clientIP filter was applied and the address had no activity there, not that the zone scope was correct.

The export also bounded the claim. It proved when requests arrived, which paths they addressed and which ones wrote state. It did not prove what the origin returned or which credential was used. I recorded that boundary in the incident notes, and the missing origin log set the retention requirement rather than disappearing behind a confident-looking CSV.

🚀 Automation & Custom AI Systems

Want a 24/7 bot or automation pipeline that never drops a lead?

Don't let customer inquiries slip away at midnight or on weekends. I build custom Telegram/WhatsApp AI assistants and deterministic workflows that connect directly to your catalogue, CRM, and order fulfillment.

Lee Teong Hoe

Lee Teong Hoe · Mr Hoelee

Full-stack developer & DevOps engineer based in Malaysia. I run my own production infrastructure and build web systems for small businesses — this blog is the living record.

Hiring? Profile & stack · Malaysian SME? Website design & development ↗ · All posts