Fluentd 解析器插件

Fluentd parser plugin

我正在尝试为 fluentd 实现一个解析器插件。下面是配置文件和插件文件。

Fluentd 配置文件。

<source>
  type syslog
  port 9010
  bind x.x.x.x
  tag flog
  format flog_message
</source>

插件文件

module Fluent
  class TextParser
    class ElogParser < Parser
      Plugin.register_parser("flog_message", self)
      config_param :delimiter, :string, :default => " " # delimiter is configurable with " " as default
      config_param :time_format, :string, :default => nil # time_format is configurable
      # This method is called after config_params have read configuration parameters
      def configure(conf)
        if @delimiter.length != 1
          raise ConfigError, "delimiter must be a single character. #{@delimiter} is not."
        end

        # TimeParser class is already given. It takes a single argument as the time format
        # to parse the time string with.
        @time_parser = TimeParser.new(@time_format)
      end

      def call(text)
        # decode text
        # ...
        # decode text 

        yield result_hash
      end
    end
  end
end

然而call方法在运行 fluentd后没有执行。非常感谢任何帮助。

从 v0.12 开始,使用 parse 而不是 call。 docs.fluentd.org 已过时,所以我刚刚更新了文章:http://docs.fluentd.org/articles/plugin-development#parser-plugins

抱歉忘记更新文档...