Rebuilding 786 Requests From Cloudflare GraphQL After Docker Log Rotation
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:
| Measurement | Value |
|---|---|
| First request | 2026-12-03 07:28:48Z |
| Last request | 2026-12-03 10:25:13Z |
| Duration | 2 h 56 min 25 s |
| Request groups | 767 |
| Requests after expansion | 786 |
| Write requests | 38 |
| POST / PUT / DELETE | 22 / 12 / 4 |
| First write | 2026-12-03 08:27:55Z |
| Last write | 2026-12-03 10:24:34Z |
| Private repositories in paths | 22 |
| Files referenced in paths | 47 |
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 edge sees only traffic that used the edge. A direct-to-origin request, an internal request or a request over a private network does not appear in the zone dataset.
- Retention is a fixed window. Thirty days is enough for this review and not enough for a slow discovery. If the incident is discovered on day 31, the edge data is gone too.
- The grouped dataset is not a forensic capture. It preserves method, path, status, user agent and time to the second, but not headers, bodies, Ray IDs or authentication outcomes. It is a timeline, not a packet capture.
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.
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.