[Fluentd]如何在fluentd中解压文件

[Fluentd]How to Unzip files in fluentd

我正在尝试使用 cat_sweep 插件在 fluentd 中处理扩展名为 .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

Link 到插件:

http://docs.fluentd.org/v0.12/articles/in_exec

但我在这里看到的问题是,我无法在 运行 时发送要解压缩的文件的路径。

谁能帮我指点一下?

看你的要求,还是可以用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>