我有来源:
<source>
@type tail
tag service
path /tmp/l.log
format json
read_from_head true
</source>
Run Code Online (Sandbox Code Playgroud)
我想对它做几个过滤器,并将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>
Run Code Online (Sandbox Code Playgroud)
到目前为止,为了使一切正常,我必须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>
Run Code Online (Sandbox Code Playgroud)
这篇路由示例文章有更多的方法可以通过重写标签等来完成,但对我来说,我喜欢使用标签,上面看起来很简单。
我已经测试了上面的配置,它工作正常。让我知道你的想法 :)。
| 归档时间: |
|
| 查看次数: |
3572 次 |
| 最近记录: |