← ClaudeAtlas

log-forensicslisted

Find the signal in large log files or log queries — bucket by time, compare error rates before and after an event, surface new or spiking messages, and correlate request IDs across services. Use when the user has logs to dig through, asks "what's in these logs", or needs to know when and why errors started.
polytheseus/sre-skills · ★ 0 · DevOps & Infrastructure · score 72
Install: claude install-skill polytheseus/sre-skills
# Log forensics Logs are too big to read. Use them like a database: **count, bucket, compare, then read a few lines**. Read only the lines your numbers point to. ## Ground rules - Never `cat` an unknown-size log into the conversation. Check the size first (`wc -l`, `ls -lh`) and sample with `head`, `tail`, `shuf -n`. - Logs often contain PII, tokens and secrets. Quote the minimum needed, and redact tokens, emails and IPs in anything you summarise. - Work in a scratch directory. Don't modify the original files. ## 1. Understand the format ```bash ls -lh <files>; wc -l <file> head -3 <file>; tail -3 <file> ``` Identify the timestamp field and format, the level or severity field, and any request/trace ID. For JSON lines, list the keys: ```bash head -200 <file> | jq -r 'keys[]' 2>/dev/null | sort | uniq -c | sort -rn ``` For compressed or rotated logs use `zcat`/`zgrep`. For journald, use `journalctl -u <unit> --since "<time>" --until "<time>" -o short-iso`. For containers, use `kubectl logs --since=…` or `docker logs --since …`. ## 2. Bucket over time Count events per minute (adjust the cut to your timestamp format) and look for the step change: ```bash # Plain text, ISO timestamps at line start: 2026-01-01T12:34:56... grep -E 'ERROR|error|Exception' <file> | cut -c1-16 | sort | uniq -c # JSON lines jq -r 'select(.level=="error") | .time[0:16]' <file> | sort | uniq -c ``` Find the **first bad minute**. Everything after it is effect. The cause is usually in the m