Multiline

Concatenate multiline or stack trace log messages.

The Multiline filter helps concatenate messages that originally belonged to one context but were split across multiple records or log lines. Common examples are stack traces or applications that print logs in multiple lines.

Along with multiline filters, you can enable one of the following built-in Fluent Bit parsers with auto-detection and multi-format support:

  • Go

  • Python

  • Ruby

  • Java (Google Cloud Platform Java stack trace format)

When using this filter:

  • The usage of this filter depends on a previous configuration of a multiline parser definition.

  • To concatenate messages read from a log file, it's highly recommended to use the multiline support in the Tail plugin itself. This is because performing concatenation while reading the log file is more performant. Concatenating messages that were originally one line, but split by Docker or CRI container engines because of their size, is supported in the Tail plugin in combination with the docker or cri parser. To concatenate application logs like stacktraces on top of that, you can use this multiline filter.

Configuration parameters

The plugin supports the following configuration parameters:

Property
Description

multiline.parser

Specify one or multiple Multiline Parser definitions to apply to the content. You can specify multiple multiline parsers to detect different formats by separating them with a comma.

multiline.key_content

Key name that holds the content to process. A multiline parser definition can specify the key_content This option allows for overwriting that value for the purpose of the filter.

mode

Mode can be parser for regular expression concatenation, or partial_message to concatenate split Docker logs.

buffer

Enable buffered mode. In buffered mode, the filter can concatenate multiple lines from inputs that ingest records one by one (like Forward), rather than in chunks, re-emitting them into the beginning of the pipeline (with the same tag) using the in_emitter instance. With buffer off, this filter won't work with most inputs, except Tail.

flush_ms

Flush time for pending multiline records. Default: 2000.

emitter_name

Name for the emitter input instance which re-emits the completed records at the beginning of the pipeline.

emitter_storage.type

The storage type for the emitter input instance. This option supports the values memory (default) and filesystem.

emitter_mem_buf_limit

Set a limit on the amount of memory the emitter can consume if the outputs provide backpressure. The default for this limit is 10M. The pipeline will pause once the buffer exceeds the value of this setting. or example, if the value is set to 10M then the pipeline pauses if the buffer exceeds 10M. The pipeline will remain paused until the output drains the buffer under the 10M limit.

Configuration example

The following example aims to parse a log file called test.log that contains some full lines, a custom Java stack trace and a Go Stack Trace.

The following example files can be located in the Fluent Bit repository.

Example files content:

This is the primary Fluent Bit YAML configuration file. It includes the parsers_multiline.yaml and tails the file test.log by applying the multiline parsers multiline-regex-test and go. Then it sends the processing to the standard output.

Running Fluent Bit with the given configuration file:

Should return something like the following:

Lines that don't match a pattern aren't considered as part of the multiline message, while the ones that matched the rules were concatenated properly.

Docker partial message use case

When Fluent Bit is consuming logs from a container runtime, such as Docker, these logs will be split when larger than a certain limit, usually 16&nbspKB. If your application emits a 100K log line, it will be split into seven partial messages. The docker parser will merge these back to one line. If instead you are using the Fluentd Docker Log Driver to send the logs to Fluent Bit, they might look like this:

Fluent Bit can re-combine these logs that were split by the runtime and remove the partial message fields. The following filter example is for this use case.

The two options for mode are mutually exclusive in the filter. If you set the mode to partial_message then the multiline.parser option isn't allowed.

Last updated

Was this helpful?