如何在 fluidd 中尾部多个文件

S A*_*rew 3 logging json elasticsearch fluentd

我已经设置了 Fluentd 记录器,并且可以使用 Fluentdtail input插件来监视文件。所有数据由 fluidd 接收,随后发布到elasticsearch集群。以下是 fluidd 的配置文件:

<source>
  @type tail
  path /home/user/Documents/log_data.json
  format json
  tag myfile
</source>

<match *myfile*>
  @type elasticsearch
  hosts 192.168.48.118:9200
  user <username>
  password <password>
  index_name fluentd
  type_name fluentd
</match>
Run Code Online (Sandbox Code Playgroud)

如您所见,我正在log_data.json使用tail. 我在同一目录中也有一个文件log_user.json,我也想监视它并将其日志发布到elasticsearch. 为此,我想用不同的标签创建另一个<source>& <match>,但它开始显示错误。

如何监视多个文件并将fluentd它们发布到elasticsearch. 我看到当我们启动时fluentd它的工作人员就启动了。是否可以启动多个工作程序,以便每个工作程序都监视不同的文件,或者使用任何其他方式来执行此操作。谁能给我指出一些好的链接/教程。

谢谢。

Nic*_*Ben 5

您可以使用多个源+匹配标签。

标签可以帮助您绑定它们。

这里有一个例子:

<source>     
  @label @mainstream
  @type tail /home/user/Documents/log_data.json
  format json
  tag myfile
</source>


<label @mainstream>
  <match **>
    @type copy

    <store>
      @type               elasticsearch
      host                elasticsearch
      port                9200
      logstash_format     true
      logstash_prefix     fluentd
      logstash_dateformat %Y%m%d
      include_tag_key     true
      type_name           access_log
      tag_key             @log_name
      <buffer>
        flush_mode            interval
        flush_interval        1s
        retry_type            exponential_backoff
        flush_thread_count    2
        retry_forever         true
        retry_max_interval    30
        chunk_limit_size      2M
        queue_limit_length    8
        overflow_action       block
      </buffer>
    </store>

  </match>
</label>
Run Code Online (Sandbox Code Playgroud)

  • 该问题要求多个文件,但示例仅显示一个。 (3认同)