无法读取logstash中的CSV文件,因为它正在自行关闭



我已经启动并运行了elasticsearch和Kibana,我想使用logstash读取日志,因此我在logstash.conf文件中传递了csv文件作为输入,但它不会读取日志并自动关闭。

这就是我运行logstash命令的方式:

D:logstash-8.1.0bin>logstash -f "D:/logstash.conf" 

logstash.conf

input{
file{
path => "D:/unicorn.csv"
start_position => beginning
}
}
output{
elasticsearch{
hosts => "localhost:9200"
index => "indexforlogstash"
}
stdout{}
}

以下是终端输出:

"Using bundled JDK: ."
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and 
will likely be removed in a future release.
Sending Logstash logs to D:/logstash-8.1.0/logs which is now configured via log4j2.properties
[2022-03-16T12:59:47,905][INFO ][logstash.runner          ] Log4j configuration path used is: 
D:logstash-8.1.0configlog4j2.properties
[2022-03-16T12:59:47,938][WARN ][logstash.runner          ] The use of JAVA_HOME has been d 
deprecated. Logstash 8.0 and later ignores JAVA_HOME and uses the bundled JDK. Running 
Logstash with the bundled JDK is recommended. The bundled JDK has been verified to work with 
each specific version of Logstash, and generally provides best performance and reliability. If 
you have compelling reasons for using your own JDK (organizational-specific compliance 
requirements, for example), you can configure LS_JAVA_HOME to use that version instead.
[2022-03-16T12:59:47,942][INFO ][logstash.runner          ] Starting Logstash 
{"logstash.version"=>"8.1.0", "jruby.version"=>"jruby 9.2.20.1 (2.5.8) 2021-11-30 2a2962fbd1 
OpenJDK 64-Bit Server VM 11.0.13+8 on 11.0.13+8 +indy +jit [mswin32-x86_64]"}
[2022-03-16T12:59:47,947][INFO ][logstash.runner          ] JVM bootstrap flags: [-Xms1g, - 
Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, - 
XX:+UseCMSInitiatingOccupancyOnly, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, - 
Djruby.compile.invokedynamic=true, -Djruby.jit.threshold=0, -Djruby.regexp.interruptible=true, 
-XX:+HeapDumpOnOutOfMemoryError, -Djava.security.egd=file:/dev/urandom, - 
Dlog4j2.isThreadContextMapInheritable=true, --add-opens=java.base/java.security=ALL-UNNAMED, -- 
add-opens=java.base/java.io=ALL-UNNAMED, --add-opens=java.base/java.nio.channels=ALL-UNNAMED, - 
-add-opens=java.base/sun.nio.ch=ALL-UNNAMED, --add-opens=java.management/sun.management=ALL- 
UNNAMED]
[2022-03-16T12:59:48,058][INFO ][logstash.settings        ] Creating directory 
{:setting=>"path.queue", :path=>"D:/logstash-8.1.0/data/queue"}
[2022-03-16T12:59:48,104][INFO ][logstash.settings        ] Creating directory 
{:setting=>"path.dead_letter_queue", :path=>"D:/logstash-8.1.0/data/dead_letter_queue"}
[2022-03-16T12:59:48,285][WARN ][logstash.config.source.multilocal] Ignoring the 
'pipelines.yml' file because modules or command line options are specified
[2022-03-16T12:59:48,347][INFO ][logstash.agent           ] No persistent UUID file found. 
Generating new UUID {:uuid=>"84410117-2fa7-499b-b55a-43a29192540e", :path=>"D:/logstash- 
8.1.0/data/uuid"}
[2022-03-16T12:59:55,063][ERROR][logstash.config.sourceloader] No configuration found in the 
configured sources.
[2022-03-16T12:59:55,424][INFO ][logstash.agent           ] Successfully started Logstash API 
endpoint {:port=>9600, :ssl_enabled=>false}
[2022-03-16T13:00:00,591][INFO ][logstash.runner          ] Logstash shut down.
[2022-03-16T13:00:00,609][FATAL][org.logstash.Logstash    ] Logstash stopped processing 
because of an error: (SystemExit) exit
org.jruby.exceptions.SystemExit: (SystemExit) exit
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:747) ~[jruby.jar:?]
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:710) ~[jruby.jar:?]
at D_3a_.logstash_minus_8_dot_1_dot_0.lib.bootstrap.environment.<main>(D:logstash- 
8.1.0libbootstrapenvironment.rb:94) ~[?:?]

有人让我知道我做错了什么。

我相信这个错误是由于斜杠造成的。在配置代码中

path => "D:unicorn.csv"

同时执行

logstash -f "D:logstash.conf" 

我还建议使用下面的命令来检查你的代码中是否有任何语法错误

logstash--config.test_and_exit-f"D: \logstash.conf">

继续发布!!!谢谢

在输出字段中,您可以添加rubybug来了解已解析为logstash的输入。这将在命令提示符中打印解析的数据

output{stdout{
codec => rubydebug
}

}

Error表示logstash无法在提供的位置找到配置。

要解决错误,请执行以下步骤:

  1. 如下修改输入中的文件路径
input{
file{
path => "D:\unicorn.csv"
start_position => beginning
}
}
  1. 还使用logstash运行配置,如下所示
D:logstash-8.1.0bin>logstash -f "D:\logstash.conf" 

相关内容

最新更新