如何在 fluentd 中拖尾多个文件
How to tail multiple files in fluentd
我已经设置了 fluentd 记录器,我可以使用 fluentd tail input
插件监控文件。 fluentd 收到的所有数据稍后都会发布到 elasticsearch
集群。下面是 fluentd 的配置文件:
<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>
如您所见,我正在使用 tail
监控 log_data.json
文件。我在同一目录 log_user.json
中也有一个文件,我也想监视它并将它的日志发布到 elasticsearch
。为此,我想用不同的标签创建另一个 <source>
& <match>
但它开始显示错误。
如何监控 fluentd
中的多个文件并将它们发布到 elasticsearch
。我看到当我们开始时 fluentd
它的工作人员已经启动。是否可以启动多个工作人员,以便他们每个人都在监视不同的文件,或者以任何其他方式进行。谁能告诉我一些好的 links/tutorials.
谢谢。
您可以使用多个来源+匹配标签。
标签可以帮助您绑定它们。
举个例子:
<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>
我已经设置了 fluentd 记录器,我可以使用 fluentd tail input
插件监控文件。 fluentd 收到的所有数据稍后都会发布到 elasticsearch
集群。下面是 fluentd 的配置文件:
<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>
如您所见,我正在使用 tail
监控 log_data.json
文件。我在同一目录 log_user.json
中也有一个文件,我也想监视它并将它的日志发布到 elasticsearch
。为此,我想用不同的标签创建另一个 <source>
& <match>
但它开始显示错误。
如何监控 fluentd
中的多个文件并将它们发布到 elasticsearch
。我看到当我们开始时 fluentd
它的工作人员已经启动。是否可以启动多个工作人员,以便他们每个人都在监视不同的文件,或者以任何其他方式进行。谁能告诉我一些好的 links/tutorials.
谢谢。
您可以使用多个来源+匹配标签。
标签可以帮助您绑定它们。
举个例子:
<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>