流利的解析器插件

时间:2015-06-12 08:22:12

标签: plugins 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不会执行。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:2)

自v0.12起,请使用parse代替call。 docs.fluentd.org已经过时,所以我刚刚更新了文章:http://docs.fluentd.org/articles/plugin-development#parser-plugins

很抱歉忘记更新文件......