Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I tune nginx to write request time to logs such that awstats can show time taken for each request?

Also, how can I see requests by time taken in awstats?

This is the current format

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';
share|improve this question
up vote 5 down vote accepted

As @Vladimir mentioned, to logs request time, edit your log_format directive as belows:

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';

and set the corresponding variables for LogFormat in awstats configuration file:

LogFormat="%host %other %host_r %time1 %methodurl %code %bytesd %refererquot %uaquot %other %extra1"

Here is an extra1 section example:

ExtraSectionName1="Time to serve requests (seconds)"
ExtraSectionFirstColumnTitle1="Number of seconds to serve the request"

Building report: -config=model -output -staticlinks > awstats.localhost.html

enter image description here

share|improve this answer
Can I drill down to the page level and see the page causing delays? – Quintin Par Oct 5 '11 at 4:56

You can use the $request_time variable, as specified here, e.g.:

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                '$status $body_bytes_sent $request_time "$http_referer" '
                '"$http_user_agent" "$http_x_forwarded_for"';

Edit: Oops, missed your second question. You can make AWStats parse the new format by using the LogFormat directive with an extraN variable and later use an ExtraSection to display the results.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.