Difference between revisions of "Track HTTP Application Response time in Nginx"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
Tags: Mobile web edit, Mobile edit
Line 4: Line 4:
  
 
http://nginx.org/en/docs/http/ngx_http_log_module.html
 
http://nginx.org/en/docs/http/ngx_http_log_module.html
 
+
<pre>
 
  log_format timed_combined '$remote_addr - $remote_user [$time_local] '
 
  log_format timed_combined '$remote_addr - $remote_user [$time_local] '
 
     '"$request" $status $body_bytes_sent '
 
     '"$request" $status $body_bytes_sent '
 
     '"$http_referer" "$http_user_agent" '
 
     '"$http_referer" "$http_user_agent" '
 
     '$request_time $upstream_response_time $pipe';
 
     '$request_time $upstream_response_time $pipe';
   
+
  </pre>
  
 
2) Modify access_log directive to use new format:
 
2) Modify access_log directive to use new format:

Revision as of 04:07, 21 April 2020

[1]

1) Add to /etc/nginx/nginx.conf

http://nginx.org/en/docs/http/ngx_http_log_module.html

 log_format timed_combined '$remote_addr - $remote_user [$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent" '
    '$request_time $upstream_response_time $pipe';
 

2) Modify access_log directive to use new format:

access_log /var/log/nginx/yourdomain.com.access.log timed_combined;

[2]

request_time This shows how long Nginx dealt with the request
upstream_response_time Gives us the time it took our upstream server (in this case Apache/mod_wsgi) to respond
pipe Shows ‘p’ in case the request was pipelined.


See also

  • https://lincolnloop.com/blog/tracking-application-response-time-nginx/
  • https://stackoverflow.com/a/39260524
  • Advertising: