Ruby Fluentd自定义解析器插件引发未初始化的常量Fluent错误

Ruby Fluentd自定义解析器插件引发未初始化的常量Fluent错误,ruby,parsing,plugins,fluentd,Ruby,Parsing,Plugins,Fluentd,我正在尝试实现一个自定义解析器插件。正如中所建议的,我创建了名为parser\u unordered\u multiline.rb的以下文件,并将其放置在/etc/td-agent/plugin/位置 # @Package: Fluentd # @Module: Unordered Multiline Parser Plugin # @Author: Amyth Singh <mail@amythsingh.com> # # Licensed und

我正在尝试实现一个自定义解析器插件。正如中所建议的,我创建了名为
parser\u unordered\u multiline.rb的以下文件,并将其放置在
/etc/td-agent/plugin/
位置

# @Package:     Fluentd
# @Module:      Unordered Multiline Parser Plugin
# @Author:      Amyth Singh <mail@amythsingh.com>
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.


module Fluent
    class TextParser
        class UnorderedMultilineParser < Parser

            Plugin.register_parser('unordered_multiline', self)

            ## Define configuration params
            config_param :delimiter, :string, :default => " "
            config_param :time_format, :string, :default => nil

            ## configures our parser plugin
            def configure(conf)
                super

                if @delimiter.length != 1
                    raise ConfigError, "delimiter must be a single character. #{@delimiter} is not."
                end

                @time_parser = TimeParser.new(@time_format)
            end


            def parse(text)
                time, key_values = text.split(" ", 2)
                time = @time_parser.parse(time)
                record = {}
                key_values.split(@delimiter).each { |kv|
                    k, v = kv.split("=", 2)
                    record[k] = v
                }

                yield time, record

            end
        end
    end
end
下面是完整的堆栈跟踪

2015-12-23 14:38:23 +0530 [info]: starting fluentd-0.10.50
2015-12-23 14:38:23 +0530 [info]: reading config file path="/etc/td-agent/td-agent.conf"
2015-12-23 14:38:23 +0530 [error]: unexpected error error="uninitialized constant Fluent::TextParser::Parser"
  2015-12-23 14:38:23 +0530 [error]: /etc/td-agent/plugin/parser_unordered_multiline.rb:21:in `<class:TextParser>'
  2015-12-23 14:38:23 +0530 [error]: /etc/td-agent/plugin/parser_unordered_multiline.rb:20:in `<module:Fluent>'
  2015-12-23 14:38:23 +0530 [error]: /etc/td-agent/plugin/parser_unordered_multiline.rb:19:in `<top (required)>'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/plugin.rb:59:in `block in load_plugin_dir'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/plugin.rb:57:in `each'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/plugin.rb:57:in `load_plugin_dir'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/engine.rb:129:in `load_plugin_dir'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:369:in `block in init_engine'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:366:in `each'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:366:in `init_engine'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:129:in `block in start'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:246:in `call'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:246:in `main_process'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:221:in `block in supervise'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:220:in `fork'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:220:in `supervise'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:126:in `start'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/command/fluentd.rb:160:in `<top (required)>'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:73:in `require'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:73:in `require'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/bin/fluentd:6:in `<top (required)>'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/bin/fluentd:23:in `load'
  2015-12-23 14:38:23 +0530 [error]: /opt/td-agent/embedded/bin/fluentd:23:in `<top (required)>'
  2015-12-23 14:38:23 +0530 [error]: /usr/sbin/td-agent:7:in `load'
  2015-12-23 14:38:23 +0530 [error]: /usr/sbin/td-agent:7:in `<main>'
2015-12-23 14:38:23 +0530 [info]: process finished code=256
2015-12-23 14:38:23 +0530 [warn]: process died within 1 second. exit.
2015-12-2314:38:23+0530[信息]:启动fluentd-0.10.50
2015-12-23 14:38:23+0530[信息]:读取配置文件路径=“/etc/td-agent/td-agent.conf”
2015-12-23 14:38:23+0530[错误]:意外错误error=“未初始化常量Fluent::TextParser::Parser”
2015-12-23 14:38:23+0530[错误]:/etc/td-agent/plugin/parser\u无序\u多行。rb:21:in`'
2015-12-23 14:38:23+0530[错误]:/etc/td-agent/plugin/parser\u无序\u多行。rb:20:in`'
2015-12-23 14:38:23+0530[错误]:/etc/td-agent/plugin/parser\u无序\u多行。rb:19:in`'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/2.1.0/rubygems/core\u ext/kernel\u require.rb:55:in'require'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/2.1.0/rubygems/core\u ext/kernel\u require.rb:55:in'require'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/plugin.rb:59:“加载中的块\插件\目录”
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/plugin.rb:57:在'each'中
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/plugin.rb:57:in'load_plugin_dir'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/engine.rb:129:in'load_plugin_dir'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:369:in`block in init_engine'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:366:in'each'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:366:in'init_engine'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:129:在“开始时块”中
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:246:in'call'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:246:in'main_process'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:221:在“监督中的块”中
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:220:in'fork'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:220:在“监督”中
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/supervisor.rb:126:在“开始”中
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/lib/fluent/command/fluentd.rb:160:in`'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/2.1.0/rubygems/core\u ext/kernel\u require.rb:73:in'require'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/2.1.0/rubygems/core\u ext/kernel\u require.rb:73:in'require'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.10.50/bin/fluentd:6:in`'
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/bin/fluentd:23:在“加载”中
2015-12-23 14:38:23+0530[错误]:/opt/td-agent/embedded/bin/fluentd:23:in`'
2015-12-23 14:38:23+0530[错误]:/usr/sbin/td代理:7:在“加载”中
2015-12-23 14:38:23+0530[错误]:/usr/sbin/td代理:7:in`'
2015-12-23 14:38:23+0530[信息]:过程完成代码=256
2015-12-23 14:38:23+0530[警告]:进程在1秒内死亡。出口
这就是我的配置文件的样子

<source>
    type tail
    path /var/log/mail/mail*
    pos_file /var/log/td-agent/tmp/access.log
    exclude_path ["/var/log/mail/*.gz", "/var/log/mail/*.zip"]
    read_from_head true
    time_format %M %d %H:%M:%S
    port 5140
    format unordered_multiline
    tag  mail
</source>


<match mail>
    type copy
    <store>
       type elasticsearch
       logstash_format true
       flush_interval 30s
    </store>
</match>

型尾
路径/var/log/mail/mail*
pos_文件/var/log/td-agent/tmp/access.log
排除路径[“/var/log/mail/*.gz”,“/var/log/mail/*.zip”]
从你的头上读出来是真的
时间\u格式%M%d%H:%M:%S
5140端口
设置无序多行的格式
标签邮件
打印副本
类型弹性搜索
logstash_格式为true
冲洗间隔30秒
我是ruby和fluentd的新手,有人能告诉我这个错误是怎么回事吗

更新 根据调查,甚至这条路似乎都是正确的

<source>
    type tail
    path /var/log/mail/mail*
    pos_file /var/log/td-agent/tmp/access.log
    exclude_path ["/var/log/mail/*.gz", "/var/log/mail/*.zip"]
    read_from_head true
    time_format %M %d %H:%M:%S
    port 5140
    format unordered_multiline
    tag  mail
</source>


<match mail>
    type copy
    <store>
       type elasticsearch
       logstash_format true
       flush_interval 30s
    </store>
</match>