如何告诉Fluentd根据“ Logger_name”过滤日志过滤日志。场地?

发布于 2025-02-12 19:59:00 字数 472 浏览 1 评论 0原文

我的代码会发出结构化日志,其中包含logger_name字段。这些日志后来通过fluentd发送到某些远程日志记录存储。我希望Fluentd过滤来自Kafka Streams库的日志。尝试了这种配置,但它不起作用:

<filter containers.**>
  @type grep
  <exclude>
    key logger_name
    pattern /org.apache.kafka.streams/
  </exclude>
</filter>

我正在使用logback和afaik,它负责添加logger_name字段,所以我认为可以肯定地假设当Fluentd看到日志时,它们已经包含此字段。

过滤器不起作用的原因是什么?

My code issues structured logs, which contain a logger_name field. These logs are later sent to some remote logging storage via fluentd. I'd like fluentd to filter logs coming from Kafka streams library. Tried this configuration, but it did not work:

<filter containers.**>
  @type grep
  <exclude>
    key logger_name
    pattern /org.apache.kafka.streams/
  </exclude>
</filter>

I'm using logback, and AFAIK, it's in charge of adding the logger_name field, so I think it's safe to assume that when fluentd sees the logs, they already contain this field.

What could be the reason the filter is not working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一绘本一梦想 2025-02-19 19:59:00

该问题不是在语法中,而是在模式字段中:

pattern /org.apache.kafka.streams/

应逃脱,制作正确的模式:

pattern /org\.apache\.kafka\.streams/

添加缺失的\后,该过滤器用作预期的。

The issue was not in the syntax, but rather in the pattern field:

pattern /org.apache.kafka.streams/

The . should be escaped, making the correct pattern:

pattern /org\.apache\.kafka\.streams/

After adding the missing \, the filter worked as expected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文