Skip to content

Instantly share code, notes, and snippets.

@awsvpc
Forked from porjo/jq_cheatsheet.md
Created May 3, 2025 03:50
Show Gist options
  • Save awsvpc/deb4508810e3746f70820122b189233f to your computer and use it in GitHub Desktop.
Save awsvpc/deb4508810e3746f70820122b189233f to your computer and use it in GitHub Desktop.
jq JSON utility - cheatsheet

Apache Logs

Output entries between 2 times, showing IP and query

$ cat access_log.json | \
  jq -r 'select (.time > "2017-10-21T02:00:00.000Z" and .time < "2017-10-22T02:00:00.000Z") | [.remote_addr,.query] | @csv'

Output entries where client IP matches prefix

$ cat access_log.json | \
  jq -r 'select ((.remote_addr | contains("1.2.3.")) and .time > "2017-11-16T03:00:00.000Z") | [.remote_addr,.host,.query] | @csv'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment