簡體   English   中英

無法啟動 Logstash 服務器並拋出錯誤

[英]Unable to start Logstash server and throwing error

我想將日志文件作為輸入傳遞給 Logstash 輸入。 我已將 /bin 添加到環境變量路徑中,以便我可以從任何地方訪問它。

下面是我的配置文件:

logstash 配置文件

input{
 path => "D:\nest\es-logging-example\log\info\info.log"
 start_position => beginning
}
output{
 elasticsearch{
    hosts => ["localhost:9200"]
    index => "indexforlogstash"
 }
}  

使用logstash -f "D:\nest\es-logging-example\logstash.conf"它后,它在終端中顯示以下錯誤。

 `
[2022-03-15T16:14:49,851][ERROR][logstash.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 11 (byte 19) after input{\r\n     
path ", :backtrace=>["C:/logstash-8.1.0/logstash- 
core/lib/logstash/compiler.rb:32:in `compile_imperative'", 
"org/logstash/execution/AbstractPipelineExt.java:189:in `initialize'", 
"org/logstash/execution/JavaBasePipelineExt.java:72:in `initialize'", 
"C:/logstash-8.1.0/logstash-core/lib/logstash/java_pipeline.rb:47:in 
`initialize'", "C:/logstash-8.1.0/logstash- 
core/lib/logstash/pipeline_action/create.rb:50:in `execute'", 
"C:/logstash-8.1.0/logstash-core/lib/logstash/agent.rb:376:in `block in 
converge_state'"]}`

這個錯誤是關於什么的?

C:\logstash-8.1.0\logstash.conf沒有找到配置

指定logstash.cong文件所在的絕對路徑:

logstash -f "D:\\nest\\es-logging-example\\logstash.conf"

您還需要修改您的配置文件如下

path => "D:\\nest\\es-logging-example\\log\\info\\info.log"

我認為您的問題是 \ 是配置文件中引用字符串中的轉義字符。

你能改變嗎

 path => "D:\nest\es-logging-example\log\info\info.log"

 path => "D:\\nest\\es-logging-example\\log\\info\\info.log"

所以路徑中的 \ 字符被轉義了。

你的配置有誤,需要說明你使用的是哪個輸入插件,根據你分享的是file輸入插件。

此外,您需要使用正斜杠。

嘗試以下操作:

input {
  file {
    path => "D:/nest/es-logging-example/log/info/info.log"
    start_position => beginning
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM