nginx日志格式

log_format unified '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$http_cookie" "$request_time" "$upstream_addr" "$fastcgi_path_info" "$upstream_
response_time"';

 

log_format unified '{"@timestamp":"$time_iso8601","remote_addr":"$remote_addr","remote_user":"$remote_user","request":"$reque
st","request_method":"$request_method","status":"$status","body_bytes_sent":"$body_bytes_sent","http_referrer":"$http_referer","http_
user_agent":"$http_user_agent","http_x_forwarded_for":"$http_x_forwarded_for","http_cookie":"$http_cookie","request_time":"$request_t
ime","upstream_addr":"$upstream_addr","fastcgi_path_info":"$fastcgi_path_info","upstream_response_time":"$upstream_response_time"}';

 

$remote_addr 上一级代理IP

$remote_user 远程客户端用户名称,用于记录浏览者进行身份验证时提供的名字,如登录百度的用户名scq2099yt,如果没有登录就是空白

[$time_local] 访问的时间与时区

$request 请求的URI和HTTP协议,这是整个PV日志记录中最有用的信息,记录服务器收到一个什么样的请求

$status 记录请求返回的http状态码,比如成功是200

$body_bytes_sent 发送给客户端的文件主体内容的大小,比如899,可以将日志每条记录中的这个值累加起来以粗略估计服务器吞吐量

$http_referer 记录从哪个页面链接访问过来的。

$http_user_agent 客户端浏览器信息

$http_x_forwarded_for 客户端的真实ip,通常web服务器放在反向代理的后面,这样就不能获取到客户的IP地址了,通过$remote_add拿到的IP地址是反向代理服务器的iP地址。反向代理服务器在转发请求的http头信息中,可以增加x_forwarded_for信息,用以记录原有客户端的IP地址和原来客户端的请求的服务器地址。

$http_cookie cookie信息

$request_time 整个请求的总时间 指的就是从接受用户请求的第一个字节到发送完响应数据的时间,即包括接收请求数据时间、程序响应时间、输出响应数据时间。

$upstream_addr upstream的地址,即真正提供服务的主机地址

$fastcgi_path_info

$upstream_response_time 是指从Nginx向后端(php-cgi)建立连接开始到接受完数据然后关闭连接为止的时间

 

posted on 2021-01-12 14:22  Ryanyanglibin  阅读(262)  评论(0编辑  收藏  举报

导航