Skip to content

Instantly share code, notes, and snippets.

@hmble
Created February 7, 2022 12:31
Show Gist options
  • Save hmble/eb4775a84e20d227a89ddf7b81719e7a to your computer and use it in GitHub Desktop.
Save hmble/eb4775a84e20d227a89ddf7b81719e7a to your computer and use it in GitHub Desktop.

a way to query structured json

A structured log file where each line is a valid json string.

Example

{"level": "info", "message": "information message"}
{"level": "warn", "message": "warn message"}

This is how we can query the objects

cat 2022-02-07.log | jq -s 'map(select(.level | contains("info")))'

where .level is key-name and "info" is key-value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment