如何在 <match> 中排除 fluentd 配置中的模式?

Ste*_* K. 2 ruby regex fluentd kubernetes

我想输出所有空值,除了match 中的一个模式。例如,我知道有一些方法可以通过 @labels 做到这一点,但我确实想在match 中排除模式。

我想这样做:

<match {all tags except **events**}>
Run Code Online (Sandbox Code Playgroud)

我做了什么:

我知道我可以像这样在match 中使用 Ruby 表达式:

<match #{tag.match(/^.*event.*$/) ? "fake_tag" : "**"}>
  @type null
</match>
Run Code Online (Sandbox Code Playgroud)

逻辑: “如果当前标签有模式 - 设置 fake_tag 跳过此匹配,否则设置 ** 输出全部为空”

但是这个表达式不起作用,因为 ENV 中没有变量 $tag。据我所知,Ruby 表达式不能使用 ${tag} 之类的配置变量。

也许我可以在匹配步骤之前设置 ENV 变量?

像这样:

<filter **event**>
  #{ENV["FLUENTD_TAG"] = ${tag}}
</filter>

<match #{FLUENTD_TAG.match(/^.*event.*$/) ? "fake_tag" : "**"}>
  @type null
</match>
Run Code Online (Sandbox Code Playgroud)

这些是我的想法,但也许有更简单的方法。

问题是 - 如何在匹配中排除模式?:-)

Max*_*bur 6

放下一个,留下一切:

<match what.you.want.to.drop>
  @type null
</match>
<match **>
  # process everything else
</match>
Run Code Online (Sandbox Code Playgroud)

删除除一个之外的所有内容:

<match what.you.want.to.stay>
  # process here or send to a label
</match>
<match **> # Optional block. It will be dropped anyways if no other matches, but with a warning printed to a fluentd log.
  # Drop everything else explicitly to avoid warning.
  @type null
</match>
Run Code Online (Sandbox Code Playgroud)