我已经设置了 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>
如你所见,我正在监控 log_data.json
使用 tail
文件.我在同一目录中也有一个文件 log_user.json
,我也想监视它并将它的日志发布到 elasticsearch
.为此,我想创建另一个 <source>
& <match>
使用不同的标签,但它开始显示错误。
如何监控 fluentd
中的多个文件并将它们发布到elasticsearch
.我知道我们什么时候开始fluentd
它的工作人员已启动。是否可以启动多个工作人员,以便他们每个人都在监视不同的文件,或者以任何其他方式进行。谁能给我指出一些好的链接/教程。
谢谢。
最佳答案
您可以使用多个来源+匹配标签。
标签可以帮助您绑定(bind)它们。
举个例子:
<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>
关于json - 如何在 fluentd 中拖尾多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50435228/