HAProxy community

How to use lua StickTable Class?

Hi there, I’m trying to get a stick-table entry for a given key from Lua.

I’m using HAproxy version 1.9.14 Built with Lua version: Lua 5.3.5


function getStickTable(sticktable)

        local t = sticktable.lookup("/usage")
        for key,value in pairs(t)
                core.log(core.debug,"stick table: "..tostring(key).."=>"..tostring(value))


        return "OK"

core.register_fetches("getStickTable", getStickTable)

I got this error log when I try to use sample-fetch from haproxy.

Mar 24 17:04:59 localhost haproxy[18267]: Lua sample-fetch 'getStickTable': runtime error: /etc/haproxy/lua-sticktable.lua:5: attempt to call a nil value (field 'lookup') from /etc/haproxy/lua-sticktable.lua:5 C function line 3.

Is there anyone who knows how to use Lua StickTable Class?
If possible I want to get some sample Lua code for testing.