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.
You can set up logrotate for nginx, in this way you can maintain logs for 30 days or more as per your requirements !
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With