[Linux] nginx记录多种响应时间

前端之家收集整理的这篇文章主要介绍了[Linux] nginx记录多种响应时间前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

官网介绍
$request_time – Full request time,starting when Nginx reads the first byte from the client and ending when Nginx sends the last byte of the response body
$upstream_connect_time – Time spent establishing a connection with an upstream server
$upstream_header_time – Time between establishing a connection to an upstream server and receiving the first byte of the response header
$upstream_response_time – Time between establishing a connection to an upstream server and receiving the last byte of the response body


$upstream_connect_time 是建立连接的时间
$upstream_header_time 从建立连接到发送第一个响应头字节的时间
$request_times 是从请求到建立连接到发送完最后一个内容字节的时间
$upstream_response_time 是从建立连接到发送完最后一个内容字节的时间,这个是我们需要关注的,因为客户端的请求和客户所在网络有关

使用下面这个日志格式,看的参数比较全

log_format apm '[$time_local]\tclient=$remote_addr\t'
               request="$request"\t request_length=$request_length\thttp_referer="$http_referer"\tbytes_sent=$bytes_sent\tbody_bytes_sent=$body_bytes_sent\tuser_agent="$http_user_agent"\tupstream_addr=$upstream_addr\tupstream_status=$upstream_status\tcookie="$http_cookie"\trequest_body="$request_body"\tdocument_root="$document_root"\tfastcgi_script_name="$fastcgi_script_name"\trequest_filename="$request_filename"\trequest_time=$request_time\tupstream_response_time=$upstream_response_time\tupstream_connect_time=$upstream_connect_time\tupstream_header_time=$upstream_header_time\t';
[03/Dec/2019:19:18:43 +0800]    client=10.222.128.170   request="POST /wa.PHP?a=list_folder&calltype=auto HTTP/1.1"      request_length=959    http_referer=http://webmail.sina.net/classic/index.PHP" bytes_sent=630  body_bytes_sent=84      user_agent=Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/63.0.3239.132 Safari/537.36"      upstream_addr=127.0.0.1:9000    upstream_status=200     cookie=language=cn; __guid=253826190.3237372183145944600.1575355793588.1697; _ga=GA1.2.1940556535 mon=0; monitor_count=7"     request_body=sactioncount="    document_root=/usr/local/sinamail/web" fastcgi_script_name=/wa.PHP"  request_filename=/usr/local/sinamail/web/wa.PHP"        request_time=0.133      upstream_response_time=0.133    upstream_connect_time=0.000    upstream_header_time=0.133

 

猜你在找的Linux相关文章