liveBook · Manning

Template format

As explained in Logs and Telemetry

The template format writes output according to user-defined content containing references to values in an event payload.

The template format writes output from user-defined content, replacing curly-braced references with values from each event payload. It can also insert an event’s time value. section 5.5

Use these references when defining a template:

  • Reference a top-level payload value with a key such as {hello}. section 5.5
  • Reference nested JSON with dot notation, such as {parent.child}, using a subset of JSONPath. section 5.5
  • Reference the log record’s timestamp with {time}. section 5.5
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

The file-output configuration combines literal text with payload references in a template and writes the result to output1.templated.txt. section 5.5

How Logs and Telemetry covers it

How deep it goes
Explains substitution, timestamps, and nested dot notation, but stops at a subset of JSONPath.
Examples
Uses a Fluent Bit configuration that writes addressing={hello} value={val} --- {time} to a file.
What it assumes
Assumes familiarity with log events, payload keys, and Fluent Bit output configuration.
What you can do after
Apply it via Fluent Bit to write event data into a custom output layout.
How it connects
Connects template format with Fluent Bit output plugins, event payloads, JSONPath, nested JSON, and file output.

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.