【问题标题】:Rsyslog forwarding over HTTP通过 HTTP 转发 Rsyslog
【发布时间】:2022-01-21 00:28:13
【问题描述】:

我希望 rsyslog 通过 HTTP 将日志消息转发到将处理它们的服务。

我没有看到 Rsyslog 的确切 http-forwarding 模块,我不想在另一个端口上创建另一个侦听器来处理传入的 TCP 连接,因为它需要TCP 输出模块。

是否可以通过 HTTP 处理程序处理 Rsyslog 消息或有哪些替代方法?

【问题讨论】:

  • 我不认为这样的东西是可用的。为什么不先把日志放到数据库里再处理呢?
  • @Luv33preet,在技术上是可行的,但是它是+1服务,我需要在出现特定事件类型时触发自定义事件->每隔一段时间查询一次数据库,例如1分钟,因为反应应该尽可能快
  • 是的,这是一项 +1 服务。但如果你没有得到任何类型的 HttpListener,也许你可以尝试我告诉你的解决方法。它不是最好的解决方案。
  • @Luv33preet,你建议每隔一段时间查询一次DB?
  • 我看到两个选项:使用已经执行 HTTP(Elasticsearch?)的输出,这意味着模拟该 API。或者您可以使用 omprog 并插入您自己的脚本。

标签: rsyslog


【解决方案1】:

从 rsyslog 版本 8.2202 开始,有 omhttp 模块。

这是您需要在 /etc/rsyslog.conf 中实现的示例:

# include the omhttp module
module(load="omhttp")

# template for each indivdual message, not the format of the resulting batch
template(name="tpl_omhttp_forwarding" type="string" string="%msg%")

# action to send ALL log (files) messages via http
*.* { 
    action(
        type="omhttp"
        server="192.1.1.1"
        serverport="443"
        template="tpl_omhttp_forwarding"

        batch="on"
        batch.format="jsonarray"
        batch.maxsize="10"

        action.resumeRetryCount="-1"
    )
}

omhttp的所有动作参数,你可以找到here

注意:

根据您使用的操作系统,您可能需要自己构建它,或使用存储库here。 对于某些平台,由于缺少或太旧的依赖关系,没有 omhttp 包。

【讨论】:

    【解决方案2】:

    有一个名为 omhttp 的新输出模块。我也在研究它,但很难找到文档。

    https://github.com/rsyslog/rsyslog/issues/3024

    编辑:更新的文档在这里 https://www.rsyslog.com/doc/v8-stable/configuration/modules/omhttp.html#message-batching

    【讨论】:

      猜你喜欢
      • 2016-08-30
      • 1970-01-01
      • 2020-04-03
      • 2018-12-13
      • 2017-11-07
      • 2019-03-30
      • 2022-11-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多