lebinh / ngxtop

Real-time metrics for nginx server
MIT License
6.49k stars 473 forks source link

How to deal with json format log ? #88

Open soeric opened 6 years ago

soeric commented 6 years ago

log format like this:

   log_format  json_full   '{'
                         '"@timestamp":"$time_iso8601",'
                         '"time_local":"$time_local",'
                         '"remote_user":"$remote_user",'
                         '"server_addr":"$server_addr",'
                         '"hostname":"$hostname",'
                         '"remote_addr":"$remote_addr",'
                         '"request_method":"$request_method",'
                         '"request":"$request",'
                         '"request_time":"$request_time",'
                         '"request_uri":"$request_uri",'
                         '"uri":"$uri",'
                         '"pid":"$pid",'
                         #'"tcpinfo_rttvar":"$tcpinfo_rttvar",'
                         #'"tcpinfo_snd_cwnd":"$tcpinfo_snd_cwnd",'
                         #'"tcpinfo_rcv_space":"$tcpinfo_rcv_space",'
                         '"tcpinfo_rtt":"$tcpinfo_rtt",'
                         '"host":"$host",'
                         '"http_name":"$http_name",'
                         '"cookie_name":"$cookie_name",'
                         '"query_string":"$query_string",'
                         '"status":"$status",'
                         '"content_length":"$content_length",'
                         '"body_bytes_sent":"$body_bytes_sent",'
                         '"http_referer":"$http_referer",'
                         '"http_user_agent":"$http_user_agent",'
                         '"http_x_forwarded_for":"$http_x_forwarded_for",'
                         '"http_x_real_ip":"$http_x_real_ip",'
                         '"http_header":"$http_header",'
                         '"bytes_sent":"$bytes_sent",'
                         '"http_range":"$http_range",'
                         '"connection":"$connection",'
                         '"connection_requests":"$connection_requests",'
                         '"request_time":"$request_time",'
                         '"upstream_addr":"$upstream_addr",'
                         '"upstream_status":"$upstream_status",'
                         '"upstream_header_time":"$upstream_header_time",'
                         '"upstream_cache_status":"$upstream_cache_status",'
                         '"upstream_connect_time":"$upstream_connect_time",'
                         '"upstream_cookie_name":"$upstream_cookie_name",'
                         '"upstream_response_time":"$upstream_response_time"'
                         '}';
Frodox commented 6 years ago

+1. I would like to parse nginx json logs too

adrianlop commented 5 years ago

same here - did anyone achieve it?