更改 Nginx 日志格式为 Json 格式
~]# vim /usr/local/nginx/conf/nginx.conf
log_format access2 '{"@timestamp":"$time_iso8601",'
'"host":"$server_addr",'
'"clientip":"$remote_addr",'
'"size":$body_bytes_sent,'
'"responsetime":$request_time,'
'"upstreamtime":"$upstream_response_time",'
'"upstreamhost":"$upstream_addr",'
'"http_host":"$host",'
'"url":"$request",'
'"domain":"$host",'
'"xff":"$http_x_forwarded_for",'
'"referer":"$http_referer",'
#'"user_agent":"$http_user_agent",'
'"status":"$status"}';
access_log /var/www/logs/access.log access2;
~]# vim /usr/local/nginx/conf/nginx.conf
log_format access_log_json '{"user_ip":"$http_x_real_ip","lan_ip":"$remote_addr","log_time":"$time_iso8601","user_req":"$request","http_code":"$status","body_bytes_sent":"$body_bytes_sent","req_time":"$request_time","user_ua":"$http_user_agent"}';
access_log /var/www/logs/access.log access_log_json;