Skip to content

Instantly share code, notes, and snippets.

@josephholsten
Created January 22, 2015 01:12
Show Gist options
  • Save josephholsten/39c5c2f475b709f2bd0d to your computer and use it in GitHub Desktop.
Save josephholsten/39c5c2f475b709f2bd0d to your computer and use it in GitHub Desktop.
Complete JSON nginx log_format
# json-log.conf - log all useful nginx variables in json formatted log
# for details about these variables, see http://nginx.org/en/docs/http/ngx_http_core_module.html#variables
log_format json-log '{'
# $arg_*
# $args
# $binary_remote_addr
'"body_bytes_sent":"$body_bytes_sent",'
'"bytes_sent":"$bytes_sent",'
'"connection":"$connection",'
# $connection_requests
# $content_length
# $content_type
# $cookie_*
# $document_root
# $document_uri
'"host":"$host",'
'"hostname":"$hostname",'
'"http_cookie":"$http_cookie"'
'"http_dnt":"$http_dnt",'
'"http_referer":"$http_referer",'
'"http_user_agent":"$http_user_agent",'
'"http_x_forwarded_for":"$http_x_forwarded_for",'
# $http_*
# $https
# $is_args
# $limit_rate
'"msec":"$msec",'
# $nginx_version
# $pid
# $pipe
# $proxy_protocol_addr
'"query_string":"$query_string",'
# $realpath_root
'"remote_addr":"$remote_addr",'
# $remote_port
# $remote_user
'"request":"$request",'
# $request_body
# $request_body_file
# $request_completion
# $request_filename
# $request_length
'"request_method":"$request_method",'
'"request_time":"$request_time",'
# $request_uri
# $scheme
# $sent_http_*
# $server_addr
'"server_name":"$server_name",'
'"server_port":"$server_port",'
'"server_protocol":"$server_protocol",'
'"status":"$status",'
# $tcpinfo_rtt
# $tcpinfo_rttvar
# $tcpinfo_snd_cwnd
# $tcpinfo_rcv_space
'"time_iso8601":"$time_iso8601",'
'"time_local":"$time_local",'
'"uri":"$uri",'
'}';
@hzbd
Copy link

hzbd commented Dec 11, 2020

Nginx logging json format(http(s)&stream):
https://gist.github.com/hzbd/9dd768087f65d6026e14642bcc859e37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment