Last active
May 20, 2020 13:39
-
-
Save byrnedo/501cf41e1139e30cbbee88126d960957 to your computer and use it in GitHub Desktop.
Json Nginx Logging
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
map $msec $millis { ~(.*)\.(.*) $2; } | |
map $time_iso8601 $time_iso8601_m { ~(.*)\+(.*) $1.$millis+$2; } | |
log_format json_combined escape=json | |
'{' | |
'"_ms": "$millis",' # Has to be here in order for timestamp to work. Wat | |
'"timestamp": "$time_iso8601_m",' | |
'"service": "sp-frontend",' | |
'"remote_addr":"$remote_addr",' | |
'"message":"[$status] $request_method $request_uri",' | |
'"method": "$request_method",' | |
'"status": $status,' | |
'"sent_length":$body_bytes_sent,' | |
'"duration_s":$request_time,' | |
'"referrer":"$http_referer",' | |
'"user_agent":"$http_user_agent",' | |
'"level": "info",' | |
'"proto": "$server_protocol",' | |
'"url": "$request_uri"' | |
'}'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment