-- CONFIGURED BY ANSIBLE -- https://stackoverflow.com/questions/62959018/fluentbit-parsing-from-path-key -- https://serverfault.com/questions/1157797/fluent-bit-how-to-extract-part-of-a-file-name-and-append-it-to-log-stream-name function add_fields(tag, timestamp, record) local filename = record["filename"] local range = string.match(filename, "^/var/log/sma/mass.[0-9]+.[^.]+.([^.]+).jsonfix$") local target = string.match(filename, "^/var/log/sma/mass.[0-9]+.([^.]+).[^.]+.jsonfix$") record["range"] = range record["target"] = target return 2, timestamp, record end