【发布时间】:2017-07-28 01:54:36
【问题描述】:
我正在尝试为 fluentd + fluentd-s3-plugin 编写一个干净的配置文件并将其用于许多文件。
我想避免为每个文件复制和粘贴每个<source> 和每个<match>,所以我想让它有点动态。到目前为止我所拥有的:
<source>
@type tail
path /var/www/blabla/blabla/log/production.log
pos_file /var/www/blabla/blabla/log/production.log.pos
tag production-log
format /(?<time>.*)/
</source>
<match production-log>
@type s3
s3_bucket xxxx
s3_region xxxx
path "staging/%Y/%m/%d/#{Socket.gethostname}/"
s3_object_key_format "%{path}productionlog-%{time_slice}-#{Socket.gethostname}-%{index}.%{file_extension}"
# if you want to use ${tag} or %Y/%m/%d/ like syntax in path / s3_object_key_format,
# need to specify tag for ${tag} and time for %Y/%m/%d in <buffer> argument.
<buffer tag,time>
@type file
tag ${tag}
path /var/www/blabla/blabla/log/buffer/
timekey 3600 # (default 3600) 1 hour partition
timekey_wait 1m
timekey_use_utc true # use utc
</buffer>
<format>
@type json
</format>
</match>
如您所见,我多次使用生产日志,所以我的问题是 2:
如何使用tag中的文件名?
如何在s3_object_key_format 中使用这个传递的标签? (我知道有注释说明但我不明白)
【问题讨论】: