Skip to content

Instantly share code, notes, and snippets.

@tobiashochguertel
Forked from panzi/jqlog.sh
Created February 22, 2026 09:48
Show Gist options
  • Select an option

  • Save tobiashochguertel/a039426fa17cdd81f822556ad878111c to your computer and use it in GitHub Desktop.

Select an option

Save tobiashochguertel/a039426fa17cdd81f822556ad878111c to your computer and use it in GitHub Desktop.
Follow JSON logs formatted using jq. You can also pass jq options after the filename for filtering.
#!/usr/bin/bash
set -eo pipefail
RED=$(echo -e '\033[0;1;31m')
NORMAL=$(echo -e '\033[0m')
if [[ $# -lt 1 ]]; then
echo "usage: $0 <logfile> [jq-options...]">&2
exit 1
fi
logfile=$1
shift
tail -f "$logfile" | while read -r line; do
echo "$line"|jq "$@" 2>/dev/null || echo "$RED$line$NORMAL"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment