来自HTTP输出插件的Logstash Capture HTTP响应 [英] Logstash Capture http response from http output plugin

查看:426
本文介绍了来自HTTP输出插件的Logstash Capture HTTP响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个logstash程序,将一些消息发布到URL. logstash没有错误,但我想知道是否有一种方法可以捕获来自url的响应,我们使用http输出插件发布了什么?

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.

推荐答案

没有愚蠢的问题;-)

不幸的是,无法从http输出插件获得任何响应.仅当您收到状态代码为<200>299的HTTP响应或调用期间发生异常(例如,由于远程服务器已关闭)时,才会记录错误.

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).

之所以这样做,是因为因为输出是任何Logstash管道中的最后一步,并且输出彼此之间无法通信,所以无论如何都无法使用响应.

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.

您需要的是一个HTTP过滤器插件,该插件将在输入之后和输出之前执行.您很幸运,因为这样的存在并在 https://github.com/elastic/logstash中进行了描述/issues/3489

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

弹性/logstash人员已经意识到对此的需求,并正在研究更多通用查找过滤器而不是仅用于HTTP.

The elastic/logstash folks have recognized a need for this and are working on a more generic lookup filter than just for HTTP.

这篇关于来自HTTP输出插件的Logstash Capture HTTP响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆