Skip to content

Instantly share code, notes, and snippets.

@gb-swatanabe
Last active November 10, 2015 07:28
Show Gist options
  • Save gb-swatanabe/c162217b179f8362fd92 to your computer and use it in GitHub Desktop.
Save gb-swatanabe/c162217b179f8362fd92 to your computer and use it in GitHub Desktop.
td-agentで半JSON化されたrails productionログをjqで見やすくする
$ zcat production_.$(date +%Y%m%d)_*.log.gz | \
awk -F"\t" '{print "{\"time\":\"" $1 "\",\"" $2 "\":" $3 "}" }' | sed -e 's/\\n/","/g' | jq "."
$ zcat production_.$(date +%Y%m%d)_*.log.gz | \
ruby -F"\t" -ane 'puts $F[2].sub(/^\{/,"{\"time\":\"#{$F[0]}\",\"tag\":\"#{$F[1]}\",")' | jq "."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment