01 · Why it’s true
Logs are text with structure: every line has fields in a known order or format. Parsing means splitting each line into fields, filtering the ones you care about, and aggregating — counting, summing, or finding top values.
Processing one line at a time keeps memory use flat no matter how large the file is, which is why streaming tools (and streaming code) scale to huge logs. Before trusting an answer, handle the lines that don’t match the format.
02 · Picture it
03 · In the interview
- A very common SRE coding question: parse a log and report something.
- Showing both a quick shell one-liner and a robust script.
- Handling malformed lines, huge files, and time windows.
04 · Practice question
“Given a web server access log, find the top 5 paths that returned 5xx errors in the last hour.”
A strong answer covers
- Stream the file; for each line parse timestamp, path, and status, and skip lines that don’t parse (count them).
- Keep lines from the last hour with a status from 500 to 599.
- Count per path in a hash map, then take the top 5 with a heap or a sort.
- Mention normalizing paths with IDs, and that a quick version is
awk+sort | uniq -c.