Fluentd Casual Talks ã«åå ããã¦ããã ãã
ããããã¨æã話ãèãã¦ããã¡ã«
ãFluentdãã°ãããã¯ä½¿ããããªãï¼ã
ã¨ãããã³ã·ã§ã³ã«ãªã£ãã®ã§æ©é試ãã¦ã¿ã¾ããã
ã¤ã³ã¹ãã¼ã«
gem install fluent # æããããªãã©ã°ã¤ã³ã gem install fluent-plugin-mongo gem install bson_ext gem install fluent-plugin-flowcounter gem install fluent-plugin-datacounter gem install fluent-plugin-growthforecast
ä»å試ãã¢ããª
ping ã®ã¬ã¹ãã³ã¹ããã°ã£ã¦ããã®ã¾ã¾growthforecastã«æãã¦å¯è¦åããã¾ã§ãç®æ¨ã¨ãã¾ãã
pingããã°ãã¹ã¯ãªãã
use strict; use utf8; use Time::Piece; use Time::HiRes qw/gettimeofday tv_interval/; use Net::Ping::External qw/ping/; while (1) { my $start = [gettimeofday]; ping(host => 'yahoo.co.jp', timeout => 3); my $end = [gettimeofday]; my $time = Time::Piece->new->strftime('%Y-%m-%dT%H:%M:%S'); printf "%s %d\n", $time, tv_interval($start, $end) * 1000; #printf "%s %.4f\n", $time, tv_interval($start, $end) * 1000; sleep 5; }
ããããã°ã«ãªãã¤ã¬ã¯ããã¦ããã
perl ping.pl > /tmp/ping.log
growthforecast
ä»åã¯ç´æ¥growthforecastã«ã¢ã¯ã»ã¹ããã®ã§
äºåã«ãã¡ããã¦ããã¾ãã
ã¤ã³ã¹ãã¼ã«ã¯å²æã以ä¸åç
§ã
http://blog.nomadscafe.jp/2011/12/growthforecast.html
fluentdã®è¨å®
ä»åã¯éä¿¡ï¼åä¿¡ãåä¸ãµã¼ãã§è¡ããã
ä¸ã¤ã®ã³ã³ãã£ã°ãã¡ã¤ã«ã«è¨è¿°ãã¾ãã
<source> type forward </source> # å ¥åï¼pingãã°ãtailã§èªã¿è¾¼ã <source> type tail format /^(?<date>[^ ]+) (?<response_time>[^ ]+)/ time_format %Y-%m-%dT%H:%M:%S path /tmp/ping.log tag net.ping pos_file /tmp/ping.log.pos </source> # åºåï¼ä¸éï¼ï¼ã¬ã¹ãã³ã¹ãéè¨ããè¨å® <match net.ping> type copy <store> type stdout </store> <store> type datacounter count_key response_time outcast_unmatched true aggregate all tag ping.result pattern1 0_10ms ^\d{1,1}$ pattern2 10_100ms ^\d{2,2}$ pattern3 100_900ms ^\d{3,3}$ pattern4 1s_over ^\d{4,}$ </store> </match> # åºåï¼éè¨ããçµæãgrothforecastã«æããè¨å® <match ping.result> type copy <store> type stdout </store> <store> type growthforecast gfapi_url http://localhost:5125/api/ service servicetest section ping2 name_keys 0_10ms_count,10_100ms_count,100_900ms_count,1s_over_count </store> </match>
fluentdèµ·å
ã³ã³ãã£ã°ãã¡ã¤ã«ãæå®ãã¦èµ·åã
ãã°ããºã©ãºã©åºã¦ãã¦èµ¤ãã®ããªããã°å¤å大ä¸å¤«ã
fluentd -c fluent.conf
éè¨
ã¾ã ã¾ã 使ãããªãã¦ãã¾ããã
datacounter / flowcounter ã¯ä½¿ãæããã¾ãããããªå°è±¡ããã°ãã
ããã使ãã°ãªã¢ã«ã¿ã¤ã éè¨ã£ã½ãã®ãåºæ¥ããã§ããï¼
ã¤ãã«Tipsçãªãã¨ã
stdoutã«ãåºåããã¨ãããã°ãã°ã¨ãã¦ä½¿ããã®ã§éå®ãã¾ããã
ãã¨
ãã°åºåããã¡ã¤ã«ã«ããããã¾ããããªãã£ããã¨ã
ping.logã§åºåããã¨ããã source type exec ã§ãã£ã¦ã¿ããã¨ãããã©
ããæ¹ãããåãããªãã£ããã¨ã
growthforecastãã©ã°ã¤ã³ã§name_keysã®éã«ã¹ãã¼ã¹å
¥ããã¨è¤æ°è¡¨ç¤ºãããªããã¨ã
ç´°ããé¨åã§ããã£ããããã
æå¾ã«ã
ãã°ç®¡çã«å°ã£ã¦ããæ¹ï¼æ¥åãæããããæ¹ã¯æ¯éã¨ãå°å
¥ãã¹ãï¼
ã§ãããã
ãããWebã®æ
å ±ã¯ã¾ã ã¾ã å°ãªãã¨æããã®ã§
æåã¯ããã¥ã¡ã³ãè¦ãªããããç¨åº¦èªåã§é å¼µãå¿
è¦ãããããããã¾ãããã
ã¬ã·ããã©ã£ãã«ã¾ã¨ã¾ã£ã¦ããã¨ãããªãã