【问题标题】:Fluentd parser pluginFluentd 解析器插件
【发布时间】:2015-06-12 17:50:52
【问题描述】:

我正在尝试为 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

但是,在运行 fluentd 之后,方法 call 并没有被执行。非常感谢任何帮助。

【问题讨论】:

    标签: plugins fluentd


    【解决方案1】:

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

    抱歉忘记更新文档...

    【讨论】:

      猜你喜欢
      • 2021-04-06
      • 1970-01-01
      • 1970-01-01
      • 2017-05-18
      • 2021-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-07
      相关资源
      最近更新 更多