Intermittent bugs hide in volume: the answer is in the logs, but the logs are 80,000 lines across three services.
Tier: Core · Workflow area: Debugging
Long-context models are genuinely good at exactly this — extraction and correlation over bulk semi-structured text — if you treat them as an extraction engine with a schema, not an oracle you ask "what went wrong?". The output is a verified incident timeline plus an anomaly set that turns "it happens sometimes" into "it happens when X".
Skip it when a log search tool answers the question in one query — grep/Loki/CloudWatch Insights first, LLM when the question needs correlation across lines, not lookup.
Cut disciplined slices, not the whole firehose. Pull each failure window with context, pre-filtered mechanically:
# 3 failure windows + 1 healthy control, all services interleaved by ts
grep -h "" api.log worker.log payments.log \
| awk '$1 >= "12:41:00" && $1 <= "12:52:00"' | sort > window1.log
Mechanical reduction (time windows, dropping DEBUG spam categories you already trust) is cheap and lossless-enough; semantic reduction is the model's job.
Extract with a schema, per window. The prompt shape that keeps it honest:
These are interleaved logs (api, worker, payments) for a window ending in
a failed checkout at 12:51:47 (request id req-8834). Build:
1. TIMELINE: every event relevant to req-8834 and to shared resources it
touched (DB pool, redis, payment gateway), as
`ts | service | event | verbatim log line`. Quote lines EXACTLY.
2. ANOMALIES: anything unusual vs normal operation in this window -
repeated retries, latency jumps, restarts, out-of-order events,
gaps > 5s in a normally chatty sequence. Same quoting rule.
3. Do not conclude a root cause yet.
Unquoted claims will be discarded.
Spot-check the quotes. Grep three or four quoted lines against the raw file. Fabricated or "cleaned-up" quotes at this stage poison everything downstream; if quotes don't check out verbatim, tighten the instruction and rerun.
Correlate across windows — failure vs control. Now the real question:
Here are timelines/anomaly sets for 3 failure windows and 1 healthy
control (attached). What is present in all failure windows and absent
from the control? List candidate discriminators ranked by consistency,
each with its supporting quotes from each window. Explicitly list
anomalies that appear in the control too - those are background noise.
A real answer looks like: "in all 3 failures, worker logs redis reconnecting 2-9s before the checkout starts; control window has no reconnects."
Convert the discriminator into a check, then a repro. Verify at scale with a mechanical query (Loki/CloudWatch/grep over weeks of history): does redis reconnecting within 10s actually precede failures at a rate far above baseline? If yes, you have the trigger condition — hand it to pb-11 to build the deterministic repro (kill the redis connection mid-checkout in a test) and fix from there.
File the byproducts. Log-forensics runs always surface secondary findings: missing correlation IDs, log-level abuse, a service logging secrets. Ticket them — next incident's forensics gets cheaper.
The model proposes the pattern; the log search tool confirms it over the full history. Never promote a discriminator to "root cause" on the extract alone — three windows is a hypothesis, not a rate.
Logs are the most regulated artifact here: they routinely contain personal data (DPDP-relevant in India), tokens, and internal topology. Options in order: run forensics inside the client's tenancy (Bedrock/Azure OpenAI-backed assistant reading logs that never leave their cloud); sanitize before pasting — a sed pass mapping user IDs/emails/hosts to stable placeholders (stable mapping matters: user_A must stay user_A across lines or correlation dies); or the chunked local-model pipeline (Ollama) — extraction-with-schema is well within local-model range, and the mechanical validation step carries the rigor regardless.