[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\t'
               'http_referer="$http_referer"\t'
               'bytes_sent=$bytes_sent\t'
               'body_bytes_sent=$body_bytes_sent\t'
               'user_agent="$http_user_agent"\t'
               'upstream_addr=$upstream_addr\t'
               'upstream_status=$upstream_status\t'
               'cookie="$http_cookie"\t'
               'request_body="$request_body"\t'
               'document_root="$document_root"\t'
               'fastcgi_script_name="$fastcgi_script_name"\t'
               'request_filename="$request_filename"\t'
               'request_time=$request_time\t'
               'upstream_response_time=$upstream_response_time\t'
               'upstream_connect_time=$upstream_connect_time\t'
               'upstream_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] nginx记录多种响应时间)