Created
November 24, 2015 20:32
-
-
Save kmjones1979/2e87f46eb650a73e27f6 to your computer and use it in GitHub Desktop.
JSON Log format for NGINX
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
log_format json '{' | |
# disabled to use timestamp in iso8601 format | |
# '"time_local": "$time_local",' | |
'"time_iso8601": "$time_iso8601",' | |
'"browser": [' | |
'{' | |
'"modern_browser": "$modern_browser",' | |
'"ancient_browser": "$ancient_browser",' | |
'"msie": "$msie"' | |
'}' | |
'],' | |
'"core": [' | |
'{' | |
'"args": "$args",' | |
'"arg": {' | |
'"arg_example": "$arg_example"' | |
'},' | |
# disabled due to invalid JSON in variable | |
# '"binary_remote_addr": "$binary_remote_addr",' | |
'"body_bytes_sent": "$body_bytes_sent",' | |
'"bytes_sent": "$bytes_sent",' | |
'"cookie": {' | |
'"cookie_example": "$cookie_example"' | |
'},' | |
'"connection": "$connection",' | |
'"connection_requests": "$connection_requests",' | |
'"content_length": "$content_length",' | |
'"content_type": "$content_type",' | |
'"document_root": "$document_root",' | |
'"document_uri": "$document_uri",' | |
'"host": "$host",' | |
'"hostname": "$hostname",' | |
'"http": {' | |
'"http_example": "$http_example"' | |
'},' | |
'"https": "$https",' | |
'"is_args": "$is_args",' | |
'"limit_rate": "$limit_rate",' | |
'"msec": "$msec",' | |
'"nginx_version": "$nginx_version",' | |
'"pid": "$pid",' | |
'"pipe": "$pipe",' | |
'"proxy_protocol_addr": "$proxy_protocol_addr",' | |
'"query_string": "$query_string",' | |
'"realpath_root": "$realpath_root",' | |
'"remote_addr": "$remote_addr",' | |
'"remote_port": "$remote_port",' | |
'"remote_user": "$remote_user",' | |
'"request": "$request",' | |
'"request_body": "$request_body",' | |
'"request_body_file": "$request_body_file",' | |
'"request_completion": "$request_completion",' | |
'"request_filename": "$request_filename",' | |
'"request_length": "$request_length",' | |
'"request_method": "$request_method",' | |
'"request_time": "$request_time",' | |
'"request_uri": "$request_uri",' | |
'"scheme": "$scheme",' | |
'"sent_http_": {' | |
'"sent_http_example": "$sent_http_example"' | |
'},' | |
'"server_addr": "$server_addr",' | |
'"server_name": "$server_name",' | |
'"server_port": "$server_port",' | |
'"server_protocol": "$server_protocol",' | |
'"status": "$status",' | |
'"tcpinfo_rtt": "$tcpinfo_rtt",' | |
'"tcpinfo_rttvar": "$tcpinfo_rttvar",' | |
'"tcpinfo_snd_cwnd": "$tcpinfo_snd_cwnd",' | |
'"tcpinfo_rcv_space": "$tcpinfo_rcv_space",' | |
'"uri": "$uri"' | |
'}' | |
'],' | |
'"fastcgi": [' | |
'{' | |
'"fastcgi_path_info": "$fastcgi_path_info",' | |
'"fastcgi_script_name": "$fastcgi_script_name"' | |
'}' | |
'],' | |
'"geoip": [' | |
'{' | |
'"geoip_area_code": "$geoip_area_code",' | |
'"geoip_city": "$geoip_city",' | |
'"geoip_city_continent_code": "$geoip_city_continent_code",' | |
'"geoip_city_country_code": "$geoip_city_country_code",' | |
'"geoip_city_country_code3": "$geoip_city_country_code3",' | |
'"geoip_city_country_name": "$geoip_city_country_name",' | |
'"geoip_country_code": "$geoip_country_code",' | |
'"geoip_country_code3": "$geoip_country_code3",' | |
'"geoip_country_name": "$geoip_country_name",' | |
'"geoip_dma_code": "$geoip_dma_code",' | |
'"geoip_latitude": "$geoip_latitude",' | |
'"geoip_longitude": "$geoip_longitude",' | |
'"geoip_org": "$geoip_org",' | |
'"geoip_postal_code": "$geoip_postal_code",' | |
'"geoip_region": "$geoip_region",' | |
'"geoip_region_name": "$geoip_region_name"' | |
'}' | |
'],' | |
'"gzip": [' | |
'{' | |
'"gzip_ratio": "$gzip_ratio"' | |
'}' | |
'],' | |
# disabled no http2 module compiled in current binary | |
# '"http2": [' | |
# '{' | |
# '"http2": "$http2"' | |
# '}' | |
# '],' | |
# | |
# disabled no variable at runtime | |
# '"memcached": [' | |
# '{' | |
# '"memcached_key": "$memcached_key"' | |
# '}' | |
# '],' | |
'"proxy": [' | |
'{' | |
'"proxy_add_x_forwarded_for": "$proxy_add_x_forwarded_for",' | |
'"proxy_host": "$proxy_host",' | |
'"proxy_port": "$proxy_port"' | |
'}' | |
'],' | |
# disabled no variable at runtime | |
# '"realip": [' | |
# '{' | |
# '"realip_remote_addr": "$realip_remote_addr"' | |
# '}' | |
# '],' | |
# | |
# disabled no variable at runtime | |
# '"referer": [' | |
# '{' | |
# '"invalid_referer": "$invalid_referer"' | |
# '}' | |
# '],' | |
'"secure_link": [' | |
'{' | |
'"secure_link": "$secure_link",' | |
'"secure_link_expires": "$secure_link_expires"' | |
'}' | |
'],' | |
'"session_log": [' | |
'{' | |
'"session_log_binary_id": "$session_log_binary_id",' | |
'"session_log_id": "$session_log_id"' | |
'}' | |
'],' | |
'"spdy": [' | |
'{' | |
'"spdy": "$spdy",' | |
'"spdy_request_priority": "$spdy_request_priority"' | |
'}' | |
'],' | |
'"ssi": [' | |
'{' | |
'"date_gmt": "$date_gmt",' | |
'"date_local": "$date_local"' | |
'}' | |
'],' | |
'"ssl": [' | |
'{' | |
'"ssl_cipher": "$ssl_cipher",' | |
'"ssl_client_cert": "$ssl_client_cert",' | |
'"ssl_client_fingerprint": "$ssl_client_fingerprint",' | |
'"ssl_client_i_dn": "$ssl_client_i_dn",' | |
'"ssl_client_raw_cert": "$ssl_client_raw_cert",' | |
'"ssl_client_s_dn": "$ssl_client_s_dn",' | |
'"ssl_client_serial": "$ssl_client_serial",' | |
'"ssl_client_verify": "$ssl_client_verify",' | |
'"ssl_protocol": "$ssl_protocol",' | |
'"ssl_server_name": "$ssl_server_name",' | |
'"ssl_session_id": "$ssl_session_id",' | |
'"ssl_session_reused": "$ssl_session_reused"' | |
'}' | |
'],' | |
'"stub_status": [' | |
'{' | |
'"connections_active": "$connections_active",' | |
'"connections_reading": "$connections_reading",' | |
'"connections_waiting": "$connections_waiting",' | |
'"connections_writing": "$connections_writing"' | |
'}' | |
'],' | |
'"uid": [' | |
'{' | |
'"uid_got": "$uid_got",' | |
'"uid_reset": "$uid_reset",' | |
'"uid_set": "$uid_set"' | |
'}' | |
'],' | |
'"upstream": [' | |
'{' | |
'"addr": "$upstream_addr",' | |
'"status": "$upstream_status",' | |
'"connect_time": "$upstream_connect_time",' | |
'"header_time": "$upstream_header_time",' | |
'"response_length": "$upstream_response_length",' | |
'"response_time": "$upstream_response_time",' | |
'"upstream_http": {' | |
'"upstream_http_example": "$upstream_http_example"' | |
'}' | |
'}' | |
']' | |
'}'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment