i want to call the rest api from logstash and want to send it to elastic search to show data in kibana dashboard.but im gettig error -
[2019-12-23T16:55:24,887][ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, => at line 14, column 25 (byte 243) after output {\r\nelasticsearch{\r\nhosts=>{\"localhost:9200\"", :backtrace=>["D:/elasticinstall/logstash-7.4.0/logstash-core/lib/logstash/compiler.rb:41:in `compile_imperative'", "D:/elasticinstall/logstash-7.4.0/logstash-core/lib/logstash/compiler.rb:49:in `compile_graph'", "D:/elasticinstall/logstash-7.4.0/logstash-core/lib/logstash/compiler.rb:11:in `block in compile_sources'", "org/jruby/RubyArray.java:2584:in `map'", "D:/elasticinstall/logstash-7.4.0/logstash-core/lib/logstash/compiler.rb:10:in `compile_sources'", "org/logstash/execution/AbstractPipelineExt.java:153:in `initialize'", "org/logstash/execution/JavaBasePipelineExt.java:47:in `initialize'", "D:/elasticinstall/logstash-7.4.0/logstash-core/lib/logstash/java_pipeline.rb:26:in `initialize'", "D:/elasticinstall/logstash-7.4.0/logstash-core/lib/logstash/pipeline_action/create.rb:36:in `execute'", "D:/elasticinstall/logstash-7.4.0/logstash-core/lib/logstash/agent.rb:326:in `block in converge_state'"]}
[2019-12-23T16:55:25,982][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
[2019-12-23T16:55:30,292][INFO ][logstash.runner ] Logstash shut down.
logstash code
input {
http_poller {
urls => {
urlname =>"http://.."
}
}
request_timeout => 60
schedule => {every=>"20s"}
codec => "line"
}
}
output {
elasticsearch{
hosts=>{"localhost:9200"}
index =>"logstash_http_poller"
}
stdout {
codec => rubydebug
}
}
command from powershell logstash -f logstash_http_poller.conf
Your elasticsearch
output is wrong, you don't need curly braces around the hosts:
elasticsearch {
hosts => "localhost:9200" <-- change this
index => "logstash_http_poller"
}
input {
http_poller {
urls =>
{
test1 => "rest api url"
}
request_timeout => 60
# Supports "cron", "every", "at" and "in" schedules by rufus scheduler
schedule => { cron => "* * * * * UTC"}
codec => "json"
# A hash of request metadata info (timing, response headers, etc.) will be sent here
metadata_target => "http_poller_metadata"
}
}
output {
stdout {
codec => rubydebug
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.