Logstash Capture http response from http output plugin

爷,独闯天下 提交于 2019-12-08 11:15:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!