Nginx、awstats 和请求时间

Qui*_*Par 1 nginx awstats

如何调整 nginx 以将请求时间写入日志,以便 awstats 可以显示每个请求所花费的时间?

另外,如何按 awstats 中的时间查看请求?

这是目前的格式

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';
Run Code Online (Sandbox Code Playgroud)

qua*_*nta 6

正如@Vladimir 提到的,要记录请求时间,请log_format按如下方式编辑您的指令:

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"'
                      ' $request_time';
Run Code Online (Sandbox Code Playgroud)

LogFormatawstats配置文件中设置相应的变量:

LogFormat="%host %other %host_r %time1 %methodurl %code %bytesd %refererquot %uaquot %other %extra1"
Run Code Online (Sandbox Code Playgroud)

这是一个extra1部分示例:

ExtraSectionName1="Time to serve requests (seconds)"
ExtraSectionCodeFilter1=""
ExtraSectionFirstColumnTitle1="Number of seconds to serve the request"
ExtraSectionFirstColumnValues1="extra1,(.*)"
ExtraSectionStatTypes1="H"
Run Code Online (Sandbox Code Playgroud)

建筑报告:

awstats.pl -config=model -output -staticlinks > awstats.localhost.html
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明