送る先のサーバが増減するだけでうん百台のtd-agentのクライアントをrestartしてまわるのが不毛なのかなと思って、
(confは送るとこはs3にあるのをincludeして読むようにしたので配らなくていいにしても)
dns_round_robin trueの軽い動作確認をしました。その記録です。
・セットで設定しとかないといけないやつ
expire_dns_cache 15
dns_round_robin true
heartbeat_type tcp
・送信元
test-komi02
・受信先
test-komi01
ip-192-168-1-174
・ドメイン:td-agent.hoge.local
# dig +noall +answer td-agent.hoge.local
td-agent.hoge.local. 47 IN A 192.168.1.174
td-agent.hoge.local. 47 IN A 192.168.3.103
・送信元の主要なconfig
<source>
type tail
format apache
path /var/log/httpd/access_log
tag apache.access.log
</source>
<match apache.access.log.**>
type copy
<store>
type forward
heartbeat_type tcp
heartbeat_interval 1s
send_timeout 61s
flush_interval 1s
buffer_queue_limit 512
buffer_type file
buffer_path /var/tmp/fluent_buf0
expire_dns_cache 10
dns_round_robin true
require_ack_response
<server>
host td-agent.hoge.local
port 24224
</server>
</store>
</match>
・受信先の主要な設定
<match apache.access.log.**>
type copy
<store>
type forest
subtype file_alternative
<template>
path /path_to_log/access_log
buffer_path /path_to_buffer/fluent_buf/__TAG__
flush_interval 1s
buffer_queue_limit 512
buffer_chunk_limit 10m
buffer_type file
</template>
</store>
</match>
テストコマンド
送信元
# for i in `seq 1 10000`; do echo '{"json":"message dayo"}' | /opt/td-agent/embedded/bin/fluent-cat apache.access.log.; done
受信先
# tail -f /path_to_log/access_log.20160804.log
ログの出方を眺めてたところ、とりあえずexpire_dns_cache 10秒にしてたので5~30秒くらいおきに出る先のサーバが変わったりしていました。
もともと設定していた以下のような送る先の設定だと、1秒前後おきに頻繁に送る先が変わっていました。
<server>
host td-agent1.hoge.local
port 24224
weight 50
</server>
<server>
host td-agent2.hoge.local
port 24224
weight 50
</server>
以上です。
参考:
http://docs.fluentd.org/articles/out_forward#dnsroundrobin
http://docs.fluentd.org/articles/out_forward#expirednscache
https://speakerdeck.com/fujiwara3/consul-casual-1