In earlier versions of haproxy, the txn.f object had a `date()` method when called from a fetch context which returned the current unix timestamp. In HAproxy 2.2, this method is removed.
The `date()` fetch is still documented and works fine from bare haproxy config, so I'm not sure why Lua can't hit it. For a minimal reproducer, stick the following in "helpers.lua": core.register_fetches("date_wrapper", function(txn) core.Debug("fetching r_u_i\n") local date = txn.f:date() core.Debug(string.format("current date is %d", date)) return string.format("%08x", date) end) Then run the following haproxy config: global maxconn 65536 lua-load "helpers.lua" hard-stop-after 30m defaults timeout server 10s timeout client 10s timeout connect 1s frontend test_fe mode http bind 127.0.0.1:9993 http-response add-header Lua-Fetch %[lua.date_wrapper] http-response add-header Regular-Fetch %[date] default_backend test_be backend test_be mode http server localhost 127.0.0.1:9992 This will work fine in haproxy 2.0.x (didn't test 2.1.x yet) and will fail with "Lua sample-fetch 'date_wrapper': runtime error: helpers.lua:3: attempt to call a nil value (method 'date') from helpers.lua:3 C function line 1" on haproxy 2.2.x. My best guess is that this is related to ae6f125c <https://github.com/haproxy/haproxy/commit/ae6f125c7b33454770aaa363101384e8daafc2a2> but I don't really understand how sample fetchers are mapped into the Lua API, so this is just a guess. Is it possible that two-optional-argument sample fetchers just don't work? I can work around this by doing `os.time()` but I'd just as soon be reusing haproxy's unix timestamp rather than doing another system call, and afaik os.time() isn't portably guaranteed to be a unix timestamp or to be in UTC. Unrelatedly: the "Lua reference manual" linked in the documentation <http://www.haproxy.org/#docs>z` ( http://www.arpalert.org/src/haproxy-lua-api/2.0dev/index.html) is now a 403. I believe the correct URL is https://www.arpalert.org/src/haproxy-lua-api/2.2dev/index.html. -- James Brown Engineer