agentleFS
polytheseuspolytheseus/sre-skills/skills/log-forensics/SKILL.md

log-forensics

Skill0 starsChanged 14 days agoMITView on GitHub

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.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. ftrout/secops-claude-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never cat an unknown-size log into the conversation.

    line 13
  2. Distinctive:

    When you have one failing request ID or trace ID, gather its whole story across files and services and sort it by time:

    line 75

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

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:

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:

# 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 minute or two before it.

3. What's new? (before vs after)

Normalise messages so that variable parts (numbers, IDs, IPs, hashes) don't split identical errors, then diff the two windows:

norm() { sed -E 's/[0-9a-f]{8}-[0-9a-f-]{27}/<uuid>/g; s/\b[0-9a-f]{12,}\b/<hex>/g; s/[0-9]+(\.[0-9]+){3}/<ip>/g; s/[0-9]+/<n>/g'; }
awk '$0 < "<T_START>"' <file> | grep -iE 'error|warn|exception' | cut -d' ' -f3- | norm | sort | uniq -c | sort -rn > before.txt
awk '$0 >= "<T_START>"' <file> | grep -iE 'error|warn|exception' | cut -d' ' -f3- | norm | sort | uniq -c | sort -rn > after.txt
# Messages present after but not before:
comm -13 <(awk '{$1="";print}' before.txt | sort) <(awk '{$1="";print}' after.txt | sort) | head -20
head -20 after.txt

(Adjust the cut so it drops the timestamp/level prefix for your format. The string comparison on $0 works for ISO-8601 timestamps at the start of the line.)

New message types, and messages whose count jumped by an order of magnitude, are your leads. Pull 3–5 full examples of each.

4. Follow a request

When you have one failing request ID or trace ID, gather its whole story across files and services and sort it by time:

grep -h '<request-id>' <files...> | sort

Note where the latency or the error first appears. The first service to log an error is usually closer to the cause than the last.

5. Common patterns

PatternSuggests
Errors begin exactly at a deploy or restart timestampThe change. Check for a version or config line at startup
Timeouts to one dependency, then cascading 5xxA downstream outage or pool exhaustion. Check connection pool or thread metrics
Errors every N minutesCron jobs, cache expiry, token refresh, log rotation
Gradual increase over hoursA leak (memory, connections, file descriptors), queue backlog, disk filling
One tenant, user or IP dominatesAn abusive client, a bad data record, or a hot key
too many open files, connection reset, broken pipeResource limits or a peer restarting

6. Report

  • When: the first bad minute (UTC), with the per-minute counts around it
  • What changed in the logs: the new or spiking messages with their counts, plus one redacted example each
  • Correlation: a deploy, restart, cron job, traffic or tenant that lines up
  • Hypothesis and confidence, and the next query that would confirm or refute it

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.