Parsers
You can define customer parsers in the parsers section of YAML configuration files.
Syntax
To define custom parsers in the parsers section of a YAML configuration file, use the following syntax.
parsers:
- name: custom_parser1
format: json
time_key: time
time_format: '%Y-%m-%dT%H:%M:%S.%L'
time_keep: on
- name: custom_parser2
format: regex
regex: '^\<(?<pri>[0-9]{1,5})\>1 (?<time>[^ ]+) (?<host>[^ ]+) (?<ident>[^ ]+) (?<pid>[-0-9]+) (?<msgid>[^ ]+) (?<extradata>(\[(.*)\]|-)) (?<message>.+)$'
time_key: time
time_format: '%Y-%m-%dT%H:%M:%S.%L'
time_keep: on
types: pid:integerFor information about supported configuration options for custom parsers, see configuring parsers.
Standalone parsers files
In addition to defining parsers in the parsers section of YAML configuration files, you can store parser definitions in standalone files. These standalone files require the same syntax as parsers defined in a standard YAML configuration file.
To add a standalone parsers file to Fluent Bit, use the parsers_file parameter in the service section of your YAML configuration file.
Add a standalone parsers file to Fluent Bit
To add a standalone parsers file to Fluent Bit, follow these steps.
Define custom parsers in a standalone YAML file. For example,
my-parsers.yamldefines two custom parsers:
parsers:
- name: custom_parser1
format: json
time_key: time
time_format: '%Y-%m-%dT%H:%M:%S.%L'
time_keep: on
- name: custom_parser2
format: regex
regex: '^\<(?<pri>[0-9]{1,5})\>1 (?<time>[^ ]+) (?<host>[^ ]+) (?<ident>[^ ]+) (?<pid>[-0-9]+) (?<msgid>[^ ]+) (?<extradata>(\[(.*)\]|-)) (?<message>.+)$'
time_key: time
time_format: '%Y-%m-%dT%H:%M:%S.%L'
time_keep: on
types: pid:integerUpdate the
parsers_fileparameter in theservicesection of your YAML configuration file:
service:
parsers_file: my-parsers.yamlLast updated
Was this helpful?