liveBook · Manning

Lua table

As explained in Logs and Telemetry

A Lua table is Lua's associative data structure for representing indexed sequences and name-value mappings, including nested values.

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

How Logs and Telemetry covers it

How deep it goes
Explains indexing, iteration, nested recursion, mutation, and callback return codes through an implementation example.
Examples
Demonstrates a recursive element counter, remote_user replacement, element_count insertion, and response-code handling.
What you can do after
Apply it via Fluent Bit Lua filters to traverse records, modify fields, and return transformed log data.
How it connects
Connects nested data with recursion, record mutation, Lua filters, timestamps, and Fluent Bit callbacks.

This explainer was generated by Manning's knowledge graph from the text of Logs and Telemetry. The section links point to the parts of the book it draws on.