lebinh/ngxtop

How to deal with json format log ?

soeric opened this issue · 2 comments

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"'
                         '}';

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

same here - did anyone achieve it?