希望在这里得到一些帮助。我的 Fluentd 设置配置为将日志发送到 2 个输出,每个输出都需要不同的日志结构。
目前为止的配置是扫描日志两次,每次添加不同的标签,并根据标签配置相关的解析和输出。
例如:
myapp.log -> tag app_splunk -> filters of type x, y, x -> match and output to splunk
myapp.log -> tag app_s3 -> different set of filters -> output to S3
我正在尝试找到一种正确的方法来处理日志一次并获得相同的结果而无需双重标记。我尝试使用 @relabel 并根据标签提供一组新的过滤器,结果是日志已经由第一个过滤器集合处理,现在新的过滤器无法正常工作。
知道我怎样才能实现这一目标吗?
<match **>
@type copy
<store>
@type relabel
@label @app_splunk
</store>
<store>
@type relabel
@label @app_s3
</store>
</match>
<label @app_splunk>
<filter **>
@type grep
<regexp>
key log_type # <- not sure what your're filtering on, replace with your own.
pattern splunk
</regexp>
</filter>
<match **>
@type splunk
...
</match>
</label @app_splunk>
<label @app_s3>
<filter **>
@type grep
<regexp>
key log_type
pattern s3
...
</label @app_splunk>
Run Code Online (Sandbox Code Playgroud)
@type copy创建独立的日志流副本。您可以根据需要制作任意数量的副本。
这还允许您在每个标签内生成重叠的子流。就像label1可以过滤掉DEBUG及以上的日志级别,而label2只能取INFO及以上的日志。因为它们是独立的流,所以INFO在这种情况下,两个目标都将接收更高的数据,并且 label1 还将接收DEBUG除此之外的数据。
| 归档时间: |
|
| 查看次数: |
1789 次 |
| 最近记录: |