I am trying to write a clean configuration file for fluentd + fluentd-s3-plugin and use it for many files.
I want to avoid copy and pasting every <source> and every <match> for every file, so I would like to make it kinda dynamic. What I have until now:
<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>
As you can see, I use production-log many times, so my questions are 2:
How do I use the filename in tag?
How do I use this passed tag in s3_object_key_format? (I know there are instructions commented but I don't get it)