Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing the total request time in seconds to an nginx access log, possibly using a calculated variable

Tags:

People also ask

What is request time in nginx log?

NGINX provides a number of built‑in timing variables that you can include in log entries. All are measured in seconds with millisecond resolution. $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.

How long are nginx logs kept?

You can set up logrotate for nginx, in this way you can maintain logs for 30 days or more as per your requirements !

What is upstream response time in nginx?

For an instance we have an API (Supposingly A) , we are capturing upstream response time of A in api log file, response time of that api lies between 1-50ms where in nginx response time is is close to 4-6seconds.

How do I find my nginx proxy log?

You can find the access logs in the logs/access. log file and change their location by using the access_log directive in the NGINX configuration file.


I'm trying to modify my nginx access log format to include the request duration, in seconds.

I see two possible variables I could use:

1) $request_time

2) $upstream_response_time

However both of these variables are expressed in microseconds, and I need this value to be rendered in seconds. Is there any way to specify the output as an expression (i.e. $request_time * 1000) or accomplish this in some other way?

Thanks