Nginx+Fluentd+GrowthForecast
さて、nginxの設定もついでにするか
http://tjun.org/blog/2012/06/fluentd-dstat-growthforecast/
nginxのログの設定
sudo vi /usr/local/nginx/conf/nginx.conf
log_format main 'time:$time_local\t' 'host:$remote_addr\t' 'request:$request\t' 'status:$status\t' 'size:$body_bytes_sent\t' 'referer:$http_referer\t' 'ua:$http_user_agent\t' 'reqtime:$request_time\t' 'upsttime:$upstream_response_time';
次にプラグイン(fluent-plugin-datacounter)をインストール
sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-datacounter
td-agentの設定の追加(/etc/td-agent/td-agent.conf)
<source> type tail path /var/log/twien.access.log tag nginx.access pos_file /tmp/fluent.log.pos time_format %d/%b/%Y:%H:%M:%S %z format ltsv </source> <match nginx.access> type copy <store> type file path /tmp/fluent-access.log </store> <store> type datacounter #unit hour count_interval 10m count_key reqtime outcast_unmatched true aggregate all tag nginx.datacount.response pattern1 0_10ms 0\.00\d+$ pattern2 10_100ms 0\.0[1-9]\d+$ pattern3 100_500ms 0\.[1-4]\d+$ pattern4 500_1000ms 0\.[5-9]\d+$ pattern5 1_1.99s 1\.\d+$ pattern6 2_4.99s [2-4]\.\d+$ pattern7 5_9.99s [5-9]\.\d+$ pattern8 10s_over \d{2,}\.\d+$ </store> </match> <match nginx.datacount.**> type copy <store> type file path /tmp/fluent-datacount.log </store> <store> type growthforecast gfapi_url http://localhost:5125/api/ service nginx tag_for section remove_prefix nginx.datacount name_key_pattern .*_count$ </store> </match>
<<追記予定>>