【问题标题】:[Fluentd]How to Unzip files in fluentd[Fluentd]如何在fluentd中解压文件
【发布时间】:2017-03-15 13:55:09
【问题描述】:

我正在尝试使用 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

的东西

插件链接:

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

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

有人可以帮我指点一下吗?

【问题讨论】:

    标签: ruby fluentd


    【解决方案1】:

    看你的需求,你仍然可以通过使用 in_exec 模块来实现它, 你需要做的是,简单地创建一个 shell 脚本,它接受路径来查找 .gz 文件和通配符模式来匹配文件名。在 shell 脚本中,您可以解压缩使用给定通配符模式传递的 folder_path 中的文件。基本上你的 shell 执行应该是这样的:

    sh unzip.sh &lt;folder_path_to_monitor&gt; &lt;wildcard_to_files&gt;

    并在配置中的 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-30
      • 2017-05-18
      • 1970-01-01
      • 1970-01-01
      • 2021-10-29
      • 1970-01-01
      • 2023-03-18
      相关资源
      最近更新 更多