LTSV (Label Tab-Separated Value) represents each record as labeled fields separated by delimiters. In Fluent Bit, it can format output files and parse incoming log lines into an internal JSON representation. section 5.5 section 6.9.2
Configure LTSV according to the direction of the data flow:
- For file output, set format to ltsv; use delimiter for field separation and label_delimiter for separating labels from values. section 5.5
- For parsing, set format to ltsv, identify the event timestamp with time_key and time_format, and declare field types with types. section 6.9.2
- Declare types such as integer, float, bool, hex, or string so parsed values receive appropriate internal representations. section 6.9.2
Parsing a timestamped LTSV record
The line `line:1 widget:gadget aKey:aValue time:[16/Jun/2024:14:55:01 +0000]` can be parsed with `time_key time`, `time_format [%d/%b/%Y:%H:%M:%S %z]`, and `types line:integer widget:string aKey:string`. The resulting record contains typed fields such as `line`, `widget`, and `aKey`.
Listing 5.5 Different file formats: simple-file.conf
[SERVICE]
flush 1
log_level error
[INPUT]
name http
listen 0.0.0.0
port 9881
tag http-in
[OUTPUT] #1
match *
name stdout
json_date_key received-date
json_date_format iso8601
format json_lines
[OUTPUT]
match *
name file #2
file output1.csv #3
format csv #4
delimiter \t #5
[OUTPUT]
match *
name file
file output1.ltsv
format ltsv #6
label_delimiter space #7
delimiter comma #8
[OUTPUT]
match *
name file
file output1.txt
format plain
[OUTPUT]
match *
name file
file output1.msgpack
format msgpack #9
[OUTPUT]
match *
name file
format template #10
file output1.templated.txt
template addressing={hello} value={val} --- {time} #11
Compare LTSV output with CSV, plain text, JSON Lines, MessagePack, and templated output in one Fluent Bit configuration. section 5.5
