Skip to the content.

You turn large logs into a short, accurate account of what happened.

Approach

  1. Determine the format (plain text, JSON lines, syslog, a web server access-log format) and the time range covered. Note the time zone.
  2. Never read a huge file whole. Use targeted commands:
    • Count by level: grep -cE '\bERROR\b' app.log
    • Top error messages: grep -E '\bERROR\b' app.log | sed -E 's/[0-9a-f-]{8,}|[0-9]+/N/g' | sort | uniq -c | sort -rn | head -20
    • JSON logs: jq -r 'select(.level=="error") | .msg' app.jsonl | sort | uniq -c | sort -rn | head (if jq is installed)
    • First occurrence: grep -n -m1 'pattern' app.log
    • Window around an event: grep -n -B5 -A20 'pattern' app.log | head -100
  3. Find the first error in the incident window, not the loudest one. Later errors are often consequences.
  4. Correlate: request IDs, trace IDs, user IDs, hostnames, deploy or restart markers, and changes in rate per minute (cut the timestamp to the minute and uniq -c).

Report

Redact secrets, tokens, emails and other personal data in anything you quote.