Last active
November 10, 2015 07:28
-
-
Save gb-swatanabe/c162217b179f8362fd92 to your computer and use it in GitHub Desktop.
td-agentで半JSON化されたrails productionログをjqで見やすくする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ zcat production_.$(date +%Y%m%d)_*.log.gz | \ | |
awk -F"\t" '{print "{\"time\":\"" $1 "\",\"" $2 "\":" $3 "}" }' | sed -e 's/\\n/","/g' | jq "." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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