Parser

The Parser Filter plugin allows to parse field in event records.

Configuration Parameters

The plugin supports the following configuration parameters:

Key Description Default
Key_Name Specify field name in record to parse.
Parser Specify the parser name to interpret the field. Multiple Parser entries are allowed (one per line).
Reserve_Data Keep original key-value pair in parsed result. False
Unescape_Key If the key is a escaped string (e.g: stringify JSON), unescape the string before to apply the parser. False

Getting Started

Configuration File

This is an example to parser a record {"data":"100 0.5 true This is example"}.

The plugin needs parser file which defines how to parse field.

  1. [PARSER]
  2. Name dummy_test
  3. Format regex
  4. Regex ^(?<INT>[^ ]+) (?<FLOAT>[^ ]+) (?<BOOL>[^ ]+) (?<STRING>.+)$

The path of parser file should be written in configuration file at [SERVICE] section.

  1. [SERVICE]
  2. Parsers_File /path/to/parsers.conf
  3. [INPUT]
  4. Name dummy
  5. Tag dummy.data
  6. Dummy {"data":"100 0.5 true This is example"}
  7. [FILTER]
  8. Name parser
  9. Match dummy.*
  10. Key_Name data
  11. Parser dummy_test
  12. [OUTPUT]
  13. Name stdout
  14. Match *

The output is

  1. $ fluent-bit -c dummy.conf
  2. Fluent-Bit v0.12.0
  3. Copyright (C) Treasure Data
  4. [2017/07/06 22:33:12] [ info] [engine] started
  5. [0] dummy.data: [1499347993.001371317, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]
  6. [1] dummy.data: [1499347994.001303118, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]
  7. [2] dummy.data: [1499347995.001296133, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]
  8. [3] dummy.data: [1499347996.001320284, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]

You can see the record {"data":"100 0.5 true This is example"} are parsed.