The firewall logs are a JSON array of nested objects. Why are they flattened before being converted to CSV, and what does the jq pipeline do?
CSV is a flat table, one value per cell, so every nested field must become its own column with a dotted name like match_table.0.rule_name; the jq pipeline lists every leaf path of each log, joins it with dots as the column name, then writes a header from the union of all keys and one row per log.
A log entry contains nested arrays and objects (match_table, proto_attr, …). CSV has no nesting, so the pipeline turns each log into a flat object first:
[.[] | [paths(scalars) as $p | {"key": $p | join("."), "value": getpath($p)}] | from_entries]: for every log, take each path that ends in a plain value, name it by joining the path with dots, and rebuild the log as one flat object.(map(keys) | add | unique) as $cols: collect every column name that occurs in any log, since different logs have different fields.map(. as $row | $cols | map($row[.])): for every log, look up each column (missing ones become empty).$cols, $rows[] | @csv: print the header line, then the rows, CSV-escaped.
The flattened file can be uploaded to Kibana, which then shows each field as a column you can filter and chart.
Version note: the lab's command uses leaf_paths. That built-in was deprecated and has been removed since jq 1.7, where the command fails with "leaf_paths/0 is not defined". paths(scalars) is the exact replacement and works in old and new versions.
* Nested JSON becomes flat columns; logs without a field get an empty cell. *
Go deeper:
jq manual —
paths(f),getpath,from_entriesand@csv.Comma-separated values (Wikipedia) — what the format can and cannot represent.