Fluentd

How to Write Parser Plugin

Fluentd supports pluggable and customizable formats for input plugins. The plugin filenames prefixed parser_ are registered as Parser Plugins.

See Plugin Base Class API for details on the common APIs for all the plugin types.

Here is an example of a custom parser that parses the following newline-delimited log format:

<timestamp><SPACE>key1=value1<DELIMITER>key2=value2<DELIMITER>key3=value...

like this:

2014-04-01T00:00:00 name=jake age=100 action=debugging

While it is not hard to write a regular expression to match this format, it is tricky to extract and save key names.

Here is the code to parse this custom format (let's call it time_key_value). It takes one optional parameter called delimiter, which is the delimiter for key/value pairs. It also takes time_format to parse the time string.

require 'fluent/plugin/parser'

module Fluent::Plugin
  class TimeKeyValueParser <