与MongoDB连接时出现Logstash警告hanshaking错误

问题描述

我正在尝试在MongoDB集合中存储一些由Logstash过滤的JSON数据日志。 Mongod实例和Logstash在同一台笔记本电脑上的Windows 8.1上运行,并且我还安装了logstash-output-mongodb插件

我的logstash配置文件在这里

# Sample Logstash configuration for receiving
# file data and importing to mongoDB

input {
  file {
    id => "my_input_plugin_id"
    path => ["C:/data/input/*.json"]
  }
}

filter {

}

output {
  stdout {
    }
  mongodb {
    uri => "mongodb://127.0.0.1:27017/test"
    database => "test"
    collection => "resultsFromLogstash"
  }
}

运行Logstash时,我会收到两条警告:

C:\logstash-7.9.2>.\bin\logstash.bat -f .\config\syslog.conf
Sending Logstash logs to C:/logstash-7.9.2/logs which is Now configured via log4j2.properties
[2020-10-05T12:57:22,787][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"7.9.2","jruby.version"=>"jruby 9.2.13.0 (2.5.7) 2020-08-039a89c94bcc Java HotSpot(TM) 64-Bit Server VM 25.261-b12 on 1.8.0_261-b12 +indy +jit [mswin32-x86_64]"}
[2020-10-05T12:57:23,131][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2020-10-05T12:57:25,866][INFO ][org.reflections.Reflections] Reflections took 36 ms to scan 1 urls,producing 22 keys and 45 values
[2020-10-05T12:57:39,774][WARN ][logstash.outputs.mongodb ][main] MONGODB | Failed to handshake with 127.0.0.1:27017: ArgumentError: wrong number of arguments (given 2,expected 1)
[2020-10-05T12:57:39,798][WARN ][logstash.outputs.mongodb ][main] MONGODB | Error running ismaster on 127.0.0.1:27017: ArgumentError: wrong number of arguments (given 2,expected 1)
[2020-10-05T12:57:40,624][INFO ][logstash.javapipeline    ][main] Starting pipeline {:pipeline_id=>"main","pipeline.workers"=>4,"pipeline.batch.size"=>125,"pipeline.batch.delay"=>50,"pipeline.max_inflight"=>500,"pipeline.sources"=>["C:/logstash-7.9.2/config/syslog.conf"],:thread=>"#<Thread:0x93192ab run>"}
[2020-10-05T12:57:41,906][INFO ][logstash.javapipeline    ][main] Pipeline Java execution initialization time {"seconds"=>1.27}
[2020-10-05T12:57:42,780][INFO ][logstash.inputs.file     ][main] No sincedb_path set,generating one based on the "path" setting {:sincedb_path=>"C:/logstash-7.9.2/data/plugins/inputs/file/.sincedb_4b1f12191afab8d266f039bc3ec0ad9c",:path=>["C:/data/input/*.json"]}
[2020-10-05T12:57:42,820][INFO ][logstash.javapipeline    ][main] Pipeline started {"pipeline.id"=>"main"}
[2020-10-05T12:57:42,945][INFO ][logstash.agent           ] Pipelines running {:count=>1,:running_pipelines=>[:main],:non_running_pipelines=>[]}
[2020-10-05T12:57:42,947][INFO ][filewatch.observingtail  ][main][my_input_plugin_id] START,creating discoverer,Watch with file and sincedb collections
[2020-10-05T12:57:43,554][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
[2020-10-05T12:57:49,944][WARN ][logstash.outputs.mongodb ][main] MONGODB | Failed to handshake with 127.0.0.1:27017: ArgumentError: wrong number of arguments (given 2,expected 1)
[2020-10-05T12:57:49,948][WARN ][logstash.outputs.mongodb ][main] MONGODB | Error running ismaster on 127.0.0.1:27017: ArgumentError: wrong number of arguments (given 2,expected 1)

在蒙古一侧:

2020-10-05T12:57:39.620+0200 I  NETWORK  [listener] connection accepted from 127.0.0.1:64554 #167 (2 connections Now open)
2020-10-05T12:57:39.685+0200 I  NETWORK  [conn167] received client Metadata from 127.0.0.1:64554 conn167: { driver: { name: "mongo-ruby-driver",version: "2.13.0" },os: { type: "mswin",name: "mswin32",architecture: "x86_64" },platform:"JRuby 9.2.13.0,like Ruby 2.5.7,java,JVM 1.8.0_261,java1.8" }
2020-10-05T12:57:41.851+0200 I  NETWORK  [conn167] end connection 127.0.0.1:64554 (1 connection Now open)
2020-10-05T12:57:49.937+0200 I  NETWORK  [listener] connection accepted from 127.0.0.1:64563 #168 (2 connections Now open)
2020-10-05T12:57:49.940+0200 I  NETWORK  [conn168] received client Metadata from 127.0.0.1:64563 conn168: { driver: { name: "mongo-ruby-driver",java1.8" }

好像mongod接受了连接,但是握手期间发生了一些错误。它说有2个参数而不是预期的1个参数,但是我不知道它指的是哪个级别。

任何帮助将不胜感激。

谢谢。

解决方法

在MongoDB端和Logstash上查找后,有人告诉我插件logstash-output-mongodb中存在一个开放问题。固定版本已可用,但不能与当前版本合并。因此,一些贡献者建议自己构建固定版本。

https://github.com/logstash-plugins/logstash-output-mongodb/pull/66

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...