diff --git a/plugins/filter_lua/lua.c b/plugins/filter_lua/lua.c
index a42cca7ca4b..3a6fef2cc1b 100644
--- a/plugins/filter_lua/lua.c
+++ b/plugins/filter_lua/lua.c
@@ -173,7 +173,7 @@ static void pack_result_mpack(lua_State *l,
         return;
     }
 
-    len = flb_lua_arraylength(l);
+    len = flb_lua_arraylength(l, -1);
     if (len > 0) {
         /* record split */
         for (i = 1; i <= len; i++) {