问题
I have wrote a logstash program to post some message to URL. there is no error from logstash but i wanted to know is there a way to capture response from the url what we post using http output plugin ?
output {
stdout {
codec => json_lines
}
http{
url => "Rest URl"
http_method => "post"
format => "json"
headers => {"Authorization" => "%{pass}"}
}
}
I had gone through the documentation but i didnot find anything realted to it. Forgive me if it is dumb question.
回答1:
There are no dumb questions ;-)
Unfortunately, there's no way to get any response from the http
output plugin. It will only log an error if you get an HTTP response whose status code is <200
or >299
or if there's an exception during the call (e.g. because the remote server is down).
The reason it is done that way is because there would be no way to use the response anyway since outputs are the last step in any Logstash pipeline and outputs do not communicate with each other.
What you need is an HTTP filter plugin, one that executes after inputs and before outputs. You're lucky because one such exists and is described at https://github.com/elastic/logstash/issues/3489
The elastic/logstash folks have recognized a need for this and are working on a more generic lookup filter than just for HTTP.
来源:https://stackoverflow.com/questions/39897198/logstash-capture-http-response-from-http-output-plugin