除了匹配中的一种模式外,我想全部输出为空。我知道有一些方法可以通过例如@labels来实现,但是我确实想排除 match 中的模式。
我想这样做:
<match {all tags except **events**}>
我做了什么:
我知道我可以像这样在 match 中使用Ruby表达式:
<match #{tag.match(/^.*event.*$/) ? "fake_tag" : "**"}>
@type null
</match>
逻辑:“如果当前标签具有模式-设置fake_tag跳过此匹配,否则将**设置为null则全部输出为空”
但是该表达式不起作用,因为ENV中没有变量$ tag。据我了解,Ruby表达式不能使用$ {tag}这样的配置变量。
也许我可以在 match 步骤之前设置ENV变量?
赞:
<filter **event**>
#{ENV["FLUENTD_TAG"] = ${tag}}
</filter>
<match #{FLUENTD_TAG.match(/^.*event.*$/) ? "fake_tag" : "**"}>
@type null
</match>
这些是我的想法,但也许有更简单的方法。
问题是-如何在匹配中排除模式? :-)
答案 0 :(得分:3)
丢弃1并保留其他所有内容:
<match what.you.want.to.drop>
@type null
</match>
<match **>
# process everything else
</match>
除以下内容外,丢弃所有内容:
<match what.you.want.to.stay>
# process here or send to label
</match>
<match **> # Optional block, it will be dropped anyways if no other matches.
# drop everything else
@type null
</match>