0

我正在尝试为 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 后不会执行。任何帮助是极大的赞赏。

4

1 回答 1

2

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

抱歉忘记更新文档...

于 2015-06-12T09:50:52.677 回答