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'"]}`
I am unable to get what's this error about.Someone please let me know any help would be appreciated.
CodePudding user response:
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.
CodePudding user response:
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"
CodePudding user response:
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
}
}