A Lua table is an associative structure for log records: name-value pairs represent fields, while nested values become tables that can be traversed and modified. section 7.6.2
Use Lua tables in Fluent Bit filters to:
- Access fields by name or numeric index. section 7.6.2
- Iterate through fields and recurse into nested tables. section 7.6.2
- Add calculated fields or replace existing values before returning the record. section 7.6.2
Counting nested record elements
A Lua callback recursively counts non-table elements, changes remote_user to Lua when present, and adds element_count to the record. Fluent Bit then receives the modified table with response code 2. section 7.6.2
Table 7.1 Response-code values and their meanings
|
Code
|
Meaning
|
|---|---|
|
–1
|
The record needs deleting.
|
|
0
|
All values are unmodified.
|
|
1
|
Both timestamp and record structures have changed, and the Fluent Bit record needs to be updated.
|
|
2
|
Only the record has changed, and the timestamp remains unmodified.
|
Use the response-code table to interpret whether a Lua callback deletes a record, leaves it unchanged, or updates its timestamp and record. section 7.6.2
