FluentdでNginxのログを送信
FluentdでNginxのログを送信
<source>
@type tail
path /var/log/nginx/access.*.log
pos_file /var/log/td-agent/nginx-access.log.pos
tag nginx.access.*
<parse>
@type nginx
keep_time_key true
</parse>
</source>
<filter nginx.access.**>
@type record_transformer
<record>
hostname ${hostname}
filename ${tag_suffix[-3]}
filepath ${tag_suffix[2]}
</record>
</filter>
<match nginx.access.**>
@type copy
# <store>
# @type stdout
# </store>
<store>
@type forward
heartbeat_interval 1
recover_wait 10 # default: 10s
phi_threshold 16 # default: 16
<server>
host 192.168.201.34
port 24224
</server>
</store>
</match>
送信先の仮想マシンのFluentdの設定
<source>
@type forward
bind 0.0.0.0
port 24224
</source>
<match nginx.access.**>
@type copy
<store>
@type file
path /logs/${hostname}/${filepath}/log.%Y%m%d
append true
add_path_suffix false
<format>
@type json
</format>
<buffer hostname,filepath,time>
flush_mode interval
flush_interval 60s
</buffer>
</store>
</match>