0

I want to pass log file as an input to a Logstash input. I have added /bin to the environment variable path so that I can access it from anywhere.

Below is my conf file:

logstash.conf

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

After running this using logstash -f "D:\nest\es-logging-example\logstash.conf" its showing below error in terminal.

 `
[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'"]}`

What is this error about?

halfer
  • 19,824
  • 17
  • 99
  • 186
Digvijay
  • 2,887
  • 3
  • 36
  • 86

3 Answers3

0

There's no configuration found in C:\logstash-8.1.0\logstash.conf

Specify the absolute path where your logstash.cong file is located instead:

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

You also need to modify your config file as follows

path => "D:\\nest\\es-logging-example\\log\\info\\info.log"
Val
  • 207,596
  • 13
  • 358
  • 360
0

I think your problem is that the \ is an escape character in the quoted string in your config file.

Can you change

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

to

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

So the \ characters in the path are escaped.

vipw
  • 7,593
  • 4
  • 25
  • 48
0

Your configuration is wrong, you need to specify which input plugin you are using, which based on what you shared is the file input plugin.

Also, you need to use forward slashes.

Try the following:

input {
  file {
    path => "D:/nest/es-logging-example/log/info/info.log"
    start_position => beginning
  }
}
leandrojmp
  • 7,082
  • 2
  • 19
  • 24
  • After adding `file` block its showing this error `[WARN ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [DESKTOP-L8UKCFI] received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/127.0.0.1:9200, remoteAddress=/127.0.0.1:2404}` – Digvijay Mar 15 '22 at 18:54
  • When I am trying to access `localhost:9200` its showing error on page instead it should show response from elasticsearch. – Digvijay Mar 15 '22 at 18:56