fluentd - fluentd:多个过滤器和匹配的一个来源
问题描述
我有来源:
<source>
@type tail
tag service
path /tmp/l.log
format json
read_from_head true
</source>
我想在它上面做几个过滤器,然后match
输出几个:
<source>
@type tail
tag service.pi2
path /tmp/out.log
format json
read_from_head true
</source>
<source>
@type tail
tag service.data
path /tmp/out.log
format json
read_from_head true
</source>
<filter service.data>
# some filtering
</filter>
<filter service.pi2>
# some filtering
</filter>
<match service.data>
@type file
path /tmp/out/data
</match>
<match service.pi2>
@type file
path /tmp/out/pi
</match>
到目前为止,为了使一切正常,我必须source
使用不同的标签进行复制。我可以让它从一个源定义中工作吗?
解决方案
您可以尝试使用插件复制和重新标记来实现此目的。示例配置如下所示。
//One Source
<source>
@type tail
tag service
path /tmp/l.log
format json
read_from_head true
</source>
//Now Copy Source Events to 2 Labels
<match service>
@type copy
<store>
@type relabel
@label @data
</store>
<store>
@type relabel
@label @pi2
</store>
</match>
//@data Label, you can perform desired filter and output file
<label @data>
<filter service>
...
</filter>
<match service>
@type file
path /tmp/out/data
</match>
</label>
//@pi2 Label, you can perform desired filter and output file
<label @pi2>
<filter service>
...
</filter>
<match service>
@type file
path /tmp/out/pi
</match>
</label>
这篇路由示例文章有更多的方法可以通过重写标签等来做到这一点,但对我来说,我喜欢使用标签,上面看起来很简单。
我已经测试了上面的配置,它工作正常。让我知道你的想法 :)。
推荐阅读
- android - 在android中调用公共类
- macos - 如何修复 osx 上 gitlab-runner exec docker 的“作业失败:无效的卷规范”
- angular - 如何从 JSON 字符串创建一个垫角表?
- html - 如何在icefaces1.8中插入html5的doctype
- react-native - 标头在 createSwitchNavigator 中不起作用
- react-native - 如何在 React Native Router Flux 选项卡中显示图标?
- c# - EF Core 导航到父类问题的 2 个属性
- python - Pandas 列对象的快速文档?
- powershell - 为什么关闭一个表单会退出整个应用程序?
- java - Spring Security 认证成功后返回 403