Home > nginx > Nginx, awstats and request time

Nginx, awstats and request time

October 4Hits:3
Advertisement

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

Answers

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)"
ExtraSectionCodeFilter1=""
ExtraSectionFirstColumnTitle1="Number of seconds to serve the request"
ExtraSectionFirstColumnValues1="extra1,(.*)"
ExtraSectionStatTypes1="H"

Building report:

awstats.pl -config=model -output -staticlinks > awstats.localhost.html

Nginx, awstats and request time

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.

Tags:nginx, awstats

Related Articles

  • Nginx, awstats and request time

    Nginx, awstats and request timeOctober 4

    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] "$

  • Apache and Nginx - Forwarding .htaccess requests to Apache?December 3

    A really simple one but it's alluding me entirely. I've set up nginx as a proxy for Apache and at the moment it's only set to allow requests for certain files through to Apache, the config line is below. Problem I'm having, I need it to send .htacces

  • Nginx Retry of Requests ( Nginx - Haproxy Combination )March 11

    I wanted to ask about Nginx Retry of Requests. I have a Nginx running at the backend which then sends the requests to HaProxy which then passes it on the web server and the request is processed. I am reloading my Haproxy config dynamically to provide

  • Nginx forward all requests to another domainOctober 24

    I have been struggling to get this whole setup to work. I've found bits and pieces on the net but nothing that solves all of my requirements. I need to do this to make IE8 work, so unfortunately my hands are tied a little. I can move some endpoints a

  • How do I tell Nginx to pass requests to different apps based on the incoming url?February 8

    How do I tell Nginx to pass requests to different apps based on the incoming url? For example, mybudgetapp.com and myshoppingapp.com both point to my server where both apps (8001, 8002) and Nginx (80) are running. When a user goes to mybudgetapp.com

  • 'No Input file specified' error - NginX / fcgi - when requesting non-existant .php fileAugust 1

    I have NginX serving a drupal site using fcgi. Attempting to browse to a non existent php file (eg. www.example.com/this-file-doesn't-exist.php) results in a white screen with this error: 'No Input file specified' I used this post to help me set it u

  • Nginx proxy by Request MethodJune 19

    Is it possible/how can I configure an Nginx location block to proxy to different backends depending on the request method (ie. GET/POST)? The reason is, I am currently handling the 2 methods at 2 different URLs (one via http proxy and the other via f

  • Apache or nginx: for 10 requests a second on a tiny server?July 20

    What would you recommend for a small server setup, maybe 10 requests a second (using php and mysql, dynamic content)? --------------Solutions------------- I'd set up nginx as a reverse proxy for Apache. Let nginx handle all the static files (images,

  • Nginx - Route all requests to single scriptAugust 14

    I have a PHP script that handles script routing and does all sorts of fancy things. It was originally designed for Apache, but I'm trying to migrate it to nginx for a few of my boxes. Right now, I'm trying to smooth things out on a test server. So th

  • How do I make Nginx redirect all requests for files which do not exist to a single php file?January 5

    I have the following nginx vhost config: server { listen 80 default_server; access_log /path/to/site/dir/logs/access.log; error_log /path/to/site/dir/logs/error.log; root /path/to/site/dir/webroot; index index.php index.html; try_files $uri /index.ph

  • nginx: dump HTTP requests for debuggingMarch 13

    Ubuntu 10.04.2 nginx 0.7.65 I see some weird HTTP requests coming to my nginx server. To better understand what is going on, I want to dump whole HTTP request data for such queries. (I.e. dump all request headers and body somewhere I can read them.)

  • nginx not serving requests to external IP addressFebruary 18

    I have nginx running on port 81. I can telnet using telnet 127.0.0.1 81 and everything is fine. But when I try to telnet to my machine from my Mac (an external IP address), I just get this error: telnet: connect to address 109.123.x.x: Connection ref

  • Nginx limit POST requests to certain pagesFebruary 22

    Is it possible in the nginx.conf file to limit incoming POST requests to just a few pages? Say I only want to allow post requests on signup.php and login.php but not on all other possible pages. Reason why I ask is that my server often gets flooded w

  • nginx passing all requests to proxyJuly 12

    I'm trying to set up nginx as a reverse proxy to serve all static assets, whilst forwarding all dynamic requests to Apache. I've followed a load of different tutorials, none of which are giving me the desired effect. My /etc/nginx/sites-available/def

  • NGINX : Keep alive requests to static content ok - Keep alive requests to php-fpm requests hang until keepalive_timeout is reachedSeptember 14

    FYI, the initial question I have posted is here, no need to read it as I was way off initially: NGINX + PHP-FPM - Strange issue when trying to display images via php-gd / readfile - Connection wont terminate I was able to track it down to keep alives

  • serving mp3s to mobile devices is flooding nginx with partial requestsSeptember 20

    I am serving mp3s with a minimalistic nginx server. What I see in my log files is that there are a lot of requests, in particular from AppleCoreMedia and sometimes Android useragents, that flood the server with short requests. Sometimes they keep req

  • why nginx rewrite post request from /login to //login?September 28

    There is a if statement, which will rewrite url when the client is Android. Everything ok. But, something got strange. Nginx will write post request /login to //login, even if the block of if statement is bank. So I got a 404 page. As the jetty serve

  • NGINX proxy ajax requestOctober 11

    I don't see what the problem is with this NGINX server configuration. I'm running a tomcat server on port 8081, jboss on 8080, and have NGINX listening on port 80. I'm sending an ajax request to port 80 and would like to have it proxy_pass to the jbo

  • nginx proxy redirecting request to different proxyMay 26

    I have three LXC containers (CN1, CN2, CN3). They each run their own Apache instance and have their own networking, so each container has their own private IP. I set up all containers to listen on the private IP only for Apache. I also set up Nginx t

  • Nginx + WordPress : 414 Request-URI Too LongJuly 5

    I use Nginx with php-fpm on my server to run my Wordpress blog. When someone share my website on Facebook, some parameters are added by Facebook and the URL looks like : https://jp.rlauzier.com/2013/07/les-courriels-et-la-securite-quelques-notions-a-

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.552 s.