Plugins Fluentd解析器插件

Plugins Fluentd解析器插件,plugins,fluentd,Plugins,Fluentd,我正在尝试为fluentd实现一个解析器插件。下面是配置文件和插件文件 Fluentd配置文件 <source> type syslog port 9010 bind x.x.x.x tag flog format flog_message </source> 类型系统日志 端口9010 绑定x.x.x.x 标签鞭打 格式化flog_消息 插件文件 module Fluent class TextParser class ElogPa

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

Fluentd配置文件

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

类型系统日志
端口9010
绑定x.x.x.x
标签鞭打
格式化flog_消息
插件文件

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
modulefluent
类文本分析器
类ElogParser“”#分隔符可配置为默认值为“”
config_param:time_format,:string,:default=>nil#可以配置time_格式
#配置参数读取配置参数后调用此方法
def配置(配置)
如果@delimiter.length!=1.
raise ConfigError,“分隔符必须是单个字符。#{@delimiter}不是。”
结束
#时间分析器类已给定。它采用单个参数作为时间格式
#使用解析时间字符串。
@time\u parser=TimeParser.new(@time\u格式)
结束
def呼叫(文本)
#解码文本
# ...
#解码文本
产生结果\u散列
结束
结束
结束
结束

但是,在运行fluentd之后,不会执行方法
调用
。非常感谢您的帮助。

从v0.12开始,请使用
parse
而不是
call
。 docs.fluentd.org已经过时,所以我刚刚更新了这篇文章:

抱歉,忘记更新文档