Regular expression format
Use the regular expression parser format to create custom parsers with Ruby regular expressions. These regular expressions use named capture to define which content belongs to which key name.
Use Tail multiline when you need to support regular expressions across multiple lines from a tail. The Tail input plugin treats each line as a separate entity.
Setting the format to regular expressions requires a regex configuration key.
For available configuration parameters, see Configuring custom parsers.
Regular expression work limit
In v5.2 or later, Fluent Bit limits how much work the regular expression engine can do for each search, which the engine calls the match operation limit. The limit applies to every regular expression in Fluent Bit, not only to parsers. A search can use up to 10,000,000 engine steps. For a search that scans the text, the steps from all starting positions count toward the same limit. The limit is set when Fluent Bit is built and can't be configured.
When a search reaches the limit, it fails, and Fluent Bit logs an error such as [regex] search failed: -17, or [router] regex match failed: -17 for tag matching. The code -17 means the limit was reached. Most features treat the failed search as no match, so the effect depends on where the expression is used:
The Parser filter keeps the original record and tries the next parser, if any.
The Syslog input logs the warning
error parsing log message with parser '<name>'and drops the message.A Grep filter
regexrule drops the record, and anexcluderule keeps it.A conditional routing
regexrule evaluates to false, and anot_regexrule evaluates to true.A
match_regexpattern on a filter or output doesn't match the tag, so the filter isn't applied, or the records aren't routed to the output. Filters match the tag each time records are added, and outputs each time a chunk is created, so the error can repeat many times for the same tag.A multiline rule treats the line as not matching.
A Tail input
tag_regexthat fails for a filename prevents that file from being read.Some features don't treat a failed search as no match. A failed search can count as a match in Sampling processor attribute conditions. The same applies to the include, exclude, ignore, allow, and deny lists of the Node exporter metrics, Process exporter metrics, and Windows exporter metrics inputs. It also applies to the name and type filters of the Thermal input. Depending on the list, the item can then be included or excluded unexpectedly. If you use regular expressions in these features, check the logs for
search failederrors.
Configuration parameters
The regex parser supports the following format-specific configuration parameter:
skip_empty_values
If enabled, the parser ignores empty values of the record.
true
Fluent Bit uses the Onigmo regular expression library in Ruby mode.
You can use only alphanumeric characters and underscore in group names. For example, a group name like (?<user-name>.*) causes an error due to the invalid dash (-) character. Use the Rubular web editor to test your expressions.
The following parser configuration example provides rules that can be applied to an Apache HTTP Server log entry:
As an example, review the following Apache HTTP Server log entry:
This log entry doesn't provide a defined structure for Fluent Bit. Enabling the proper parser can help to make a structured representation of the entry:
Last updated
Was this helpful?