Hi,
I'm using the lua module to produce randomly generated IDs for each request (and its response). My nginx.conf looks a little like this:
------
log_format rids '$request_id ...';
access_log /var/log/access.log rids;
server {
listen 80 default;
...
access_by_lua_file /var/nginx/lua/request_ids.lua;
}
-----
and the request_ids.lua looks like this:
-----
function newGuid ()
return ngx.md5(ngx.var.pid .. ngx.req.start_time() .. math.random() .. ngx.var.remote_addr .. ngx.var.request)
end
ngx.var.request_id = newGuid()
-----
This, as I understand it, should set the nginx var request_id to the value of newGuid() for every request, allowing us to add $request_id to each log entry.
However, about 25% of the access.log entries don't have a request_id value- the value is just empty (what we initialise request_id to before the access_by_lua_file statement).
Is there a reason access_by_lua_file would execute after request_id was initialised to an empty value? Any other idea why we're missing values for such a high proportion of requests.
Huge thanks in advance!
Paul
uSwitch is a trading name of uSwitch Ltd. Registered in England and Wales (Company No. 03612689). Registered Address: Notcutt House, 36 Southwark Bridge Road, London, SE1 9EU
This communication and any attachments contains information which is confidential and may be subject to legal privilege. It is for intended recipients only. If you are not the intended recipient you must not copy, distribute, publish, rely on or otherwise use it without our consent. Some of our communications may contain confidential information which it could be a criminal offence for you to disclose or use without authority. If you have received this email in error please notify the sender immediately and delete the email from your computer.
uSwitch Ltd reserves the right to monitor all email communications for compliance with legal, regulatory and professional standards.