【问题标题】:Error while running logstash for mongodb connection为 mongodb 连接运行 logstash 时出错
【发布时间】:2020-10-06 21:02:48
【问题描述】:

运行时出现此错误。 我正在尝试在 mongodb 和 elasticsearch 之间添加连接。 通过logstash添加数据进行持续监控。 然后我们将添加到 Kibana。 但是遇到这个错误,不知道是conf文件格式问题还是什么?

# bin/logstash -f /etc/logstash/conf.d/mongodata.conf --config.debug
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.headius.backport9.modules.Modules (file:/usr/share/logstash/logstash-core/lib/jars/jruby-complete-9.2.11.1.jar) to method sun.nio.ch.NativeThread.signal(long)
WARNING: Please consider reporting this to the maintainers of com.headius.backport9.modules.Modules
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
[WARN ] 2020-06-17 11:12:25.705 [main] runner - --config.debug was specified, but log.level was not set to 'debug'! No config info will be logged.
[WARN ] 2020-06-17 11:12:25.937 [LogStash::Runner] multilocal - Ignoring the 'pipelines.yml' file because modules or command line options are specified
[INFO ] 2020-06-17 11:12:25.939 [LogStash::Runner] runner - Starting Logstash {"logstash.version"=>"7.7.0"}
[ERROR] 2020-06-17 11:12:26.495 [Converge PipelineAction::Create<main>] agent - Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of [ \\t\\r\\n], \"#\", \"{\" at line 2, column 15 (byte 23) after input {\n        \"uri\" ", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:58:in `compile_imperative'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:66:in `compile_graph'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:28:in `block in compile_sources'", "org/jruby/RubyArray.java:2577:in `map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:27:in `compile_sources'", "org/logstash/execution/AbstractPipelineExt.java:181:in `initialize'", "org/logstash/execution/JavaBasePipelineExt.java:67:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:43:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:52:in `execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:342:in `block in converge_state'"]}
[INFO ] 2020-06-17 11:12:26.649 [Api Webserver] agent - Successfully started Logstash API endpoint {:port=>9600}
[INFO ] 2020-06-17 11:12:31.694 [LogStash::Runner] runner - Logstash shut down.

这是我的配置文件:

input {
        "uri" => "mongodb://liquid.nvidia.com:27017/"
        "placeholder_db_dir" => "/opt/logstash-mongodb/"
        "placeholder_db_name" => "logstash_sqlite.db"
        "collection" => "global_queue_list"
        "batch_size" => 5000
}
filter {

}
output {
        stdout {
                codec => rubydebug
        }
        elasticsearch {
                "action" => "index"
                "index" => "mongo_log_data"
                "hosts" => ["localhost:9200"]
        }
}

【问题讨论】:

    标签: mongodb elasticsearch automation logstash kibana


    【解决方案1】:

    您缺少mongodb 输入插件(请参阅here

    input {
        mongodb {
            "uri" => "mongodb://liquid.nvidia.com:27017/"
            "placeholder_db_dir" => "/opt/logstash-mongodb/"
            "placeholder_db_name" => "logstash_sqlite.db"
            "collection" => "global_queue_list"
            "batch_size" => 5000
        }
    }
    

    【讨论】:

    • 感谢您的回答,安装插件后也没有出现同样的错误
    • 您是否在第二行添加了mongodb 位?
    • 赞!安装插件后我错过了 mongodb ! :)
    • 但是当我将它指向另一个数据库时又遇到了一个错误input { mongodb { "uri" =&gt; "mongodb://liquid.nvidia.com:27017/Test_info" "placeholder_db_dir" =&gt; "/opt/logstash-mongodb/" "placeholder_db_name" =&gt; "logstash_sqlite.db" "collection" =&gt; "global_queue_list" "batch_size" =&gt; 5000 } }
    • 我也为 Test_info db 更改了 placeholder_db_name。收到此错误:[main] Pipeline aborted due to error {:pipeline_id=>"main", :exception=>#,
    猜你喜欢
    • 1970-01-01
    • 2017-07-24
    • 1970-01-01
    • 2015-10-26
    • 1970-01-01
    • 2020-04-27
    • 1970-01-01
    • 1970-01-01
    • 2019-12-27
    相关资源
    最近更新 更多