Created
November 16, 2014 18:38
-
-
Save bru/ed89bf695fdb98f1dfed to your computer and use it in GitHub Desktop.
expand query params in jsonified apache log file
This file contains hidden or 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
#!/bin/sh | |
# | |
# this scripts expands the query string for jsonified apache logs. | |
# In order to work, it expects an apache log as produced by: | |
# | |
# LogFormat "{\"time\":\"%t\", \"remoteIP\":\"%a\", \"forwardedFor\":\"%{X-Forwarded-For}i\", \"host\":\"%V\", \"pid\":\"%P\", \"request\":\"%U\", \"query\":\"%q\", \"method\":\"%m\", \"status\":\"%>s\", \"userAgent\":\"%{User-Agent}i\", \"referer\":\"%{Referer}i\", \"requestTime\":\"%D\"}" jsonlog | |
sed -r 's/"query":"\?([^"]+)"/"query":{ \&\1 }/' | | |
sed -r ' | |
/"query":\{/, /\}/ { | |
s/\&([^=]+)=([^\& ]+)/"\1":"\2"/g | |
s/""/","/g | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment