Zabbix で fluentd のbuffer・キュー等の項目を監視する
fluent(td-agent)サーバ構築時、buffer等の監視設定時のメモ。
Buffer溢れ、転送先サーバ接続不可などの検知に使用出来ればと考えた。
設定方法を下記へ記載しておく。
- 以下監視項目
- buffer_queue_length -> (バッファーに蓄積されているキューの数)buffer_queue_limitで設定した値を超えるとログデータがロストするので注意
- buffer_total_queued_size -> (バッファーに蓄積されている合計サイズ)buffer_queue_limit×buffer_chunk_limitの値を超えるとログデータがロストするので注意
- retry_count -> ( 再送を試みた回数)retry_limitで設定した回数を超えるとバッファーがリセットされるので注意
- dirused -> ( フォルダ容量)Bufferに指定されているフォルダ総容量
- bufnum -> ( フォルダファイル数)Bufferに指定されているフォルダファイル数
- filetime -> ( フォルダ日時)Bufferに指定されているフォルダに保存されているもっとも古いファイルスタンプ
■以下、zabbixのuserparameter設定
# cat /etc/zabbix/zabbix_agentd.d/userparameter_fluentd.conf ## # $1: 24220 or 24221 or 24222 # $2: buffer_queue_length or buffer_total_queued_size or retry_count # UserParameter=fluentd.queue.get[*],curl -s "localhost:$1/api/plugins.json" | /usr/bin/jq ".plugins[] | .$2" | sort -nr |grep -v null | head -n1 #UserParameter=fluentd.queue.get[*],/root/fluentd.queue.get.sh $1 $2 # cat /etc/zabbix/zabbix_agentd.d/userparameter_td-agent.conf UserParameter=td-agent.dirused[*],du -bs $1 | cut -f1 2>/dev/null UserParameter=td-agent.bufnum[*],ls -lt $1 2>/dev/null | wc -l UserParameter=td-agent.filetime[*],ls -trl --time-style='+%s' $1 | head -n2 | sed -e '1d' | sed -E 's/\s+/,/g' | cut -d, -f6 2>/dev/null UserParameter=td-agent.chunknum[*],ls /data/buffer/secure-forward_tag.* |wc -l
また、過去に別途shファイルを起動した形式でしたが上記にまとめた。
# cat /root/fluentd.queue.get.sh #!/bin/bash ## # $1: 24220 or 24221 or 24222 # PORT=$1 ## # $2: buffer_queue_length or buffer_total_queued_size or retry_count # VALUE=$2 curl -s "localhost:${PORT}/api/plugins.json" | /usr/bin/jq ".plugins[] | .${VALUE}"
後は、zabbixの管理画面でよしなに設定すれば監視される。