我正在尝试使用cat_sweep插件以流利的方式处理扩展名为.gz的日志文件,但在我的尝试中失败了。如下面的配置所示,我正在尝试处理 / opt / logfiles / * 位置下的所有文件。但是,当文件格式为.gz时,cat_sweep无法处理该文件,并开始删除该文件,但如果我在 / opt / logfiles / 位置内手动解压缩该文件,则cat_sweep能够进程,文件。
<source>
@type cat_sweep
file_path_with_glob /opt/logfiles/*
format none
tag raw.log
waiting_seconds 0
remove_after_processing true
processing_file_suffix .processing
error_file_suffix .error
run_interval 5
</source>
所以现在我需要一些可以解压缩给定文件的插件。我尝试搜索可以解压缩压缩文件的插件。当我发现插件时,我接近了,它就像一个终端,我可以使用像 gzip -d file_path
这样的东西链接到该插件:
http://docs.fluentd.org/v0.12/articles/in_exec
但我在这里看到的问题是,我无法在运行时发送文件的路径解压缩。
有人可以帮我提一些指示吗?
答案 0 :(得分:2)
查看您的要求,您仍然可以使用 in_exec 模块实现此目标, 您需要做的是,简单地创建一个shell脚本,该脚本接受查找.gz文件的路径以及匹配文件名的通配符模式。在shell脚本中,您可以解压缩使用给定通配符模式传递的folder_path中的文件。基本上你的shell执行应该如下:
<强> sh unzip.sh <folder_path_to_monitor> <wildcard_to_files>
强>
在配置中的 in_exec 标记中使用上述命令。您的配置将如下所示:
<source>
@type exec
format json
tag unzip.sh
command sh unzip.sh <folder_path_to_monitor> <wildcard_to_files>
run_interval 10s
</source>