Lion Cipher Lab

Slice and query JSON logs with jq

Why it matters

The logs a defender reads today are mostly JSON, not plain text. Cloud platforms (AWS, Azure, Google Cloud), Kubernetes, and a huge range of security tools all write their events as JSON, because a machine-readable format is easy for other machines to search and ship around. The catch is that grep — the classic line-by-line text filter — is clumsy on JSON, because the meaning lives in named fields, not in a line's position. jq is the small, universal tool built exactly for this: it lets you pick fields, filter events, and count patterns out of JSON in one line. Learn it once and you can…

What you'll learn

Steps in this lab

  1. What JSON is, in plain words
  2. Open a terminal and install jq
  3. Make a sample JSON log to practise on
  4. Pretty-print the log — meet the filter and the pipe
  5. Select fields, including nested ones
  6. Filter to just the events that matter with select()
  7. Count and group — how many, and by what
  8. Build the one-liner that pulls suspicious events out
  9. Why this small skill travels so far

Open the full interactive lab →