我在将请求正文中的XML设置为http_poller端点时遇到困难。当我在http_poller端点中设置请求正文时显示错误
[ERROR] 2018-08-10 08:10:36.703 [Converge PipelineAction::Create<main>] agent - Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, => at line 16, column 9 (byte 713) after input {\n http_poller {\n\tschedule => { cron => \"* * * * * UTC\"}\n # List of urls to hit\n # URLs can either have a simple format for a get request\n # Or use more complex HTTP features\n urls => {\n some_other_service => {\n method => \"post\"\n url => \"url to post\" \n headers => {\n Accept => \"application/xml\"\n } \n\tbody => {\n '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ReqListLocation><User><Login>username111</Login><Password>password</Password></User><Location><Disabled>1</Disabled><Type>P</Type></Location></ReqListLocation>'\n ", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:42:incompile_imperative'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:50:in compile_graph'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:12:inblock in compile_sources'", "org/jruby/RubyArray.java:2486:in map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:11:incompile_sources'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:49:in initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:167:ininitialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:40:in execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:305:inblock in converge_state'"]}`
我的conf文件
input {
http_poller {
schedule => { cron => "* * * * * UTC"}
# List of urls to hit
# URLs can either have a simple format for a get request
# Or use more complex HTTP features
urls => {
some_other_service => {
method => "post"
url => "I have removed the url due to securuty purposes"
headers => {
Accept => "application/xml"
}
body => {
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ReqListLocation><User><Login>username111</Login><Password>password!</Password></User><Location><Disabled>1</Disabled><Type>P</Type></Location></ReqListLocation>'
}
}
}
# Maximum amount of time to wait for a request to complete
request_timeout => 30
# How far apart requests should be
#interval => 60
# Decode the results as xml
codec => "xml"
# Store metadata about the request in this key
metadata_target => "http_poller_metadata"
}
}
output {
stdout {
codec => rubydebug
}
}