ãã¯ãã«ã«ã°ã«ã¼ãã®å®®æ¾¤ã§ãã
ä»åã¯ãfluentdã¨S3ã使ã£ã¦S3ã«ãã°ãã¢ã¼ã«ã¤ãããæé ãç´¹ä»ãã¾ãã
fluentdã¨ã¯ããã°ãåéãæ ¼ç´ããããã®ãã°åéåºç¤ã½ããã¦ã§ã¢ã§ãã
fluentdã«èªã¿è¾¼ã¾ãããã°ã¯JSONå½¢å¼ã«å¤æãããæå®ã®å ´æã«ã¢ã¦ããããããã¾ãã
â»fluentdã®å®å®ç¨¼åçã¯td-agentã¨ãªãã¾ãã
fluentdã®ã¤ã³ã¹ãã¼ã«
ãªãã¸ããªã®è¿½å
__| __|_ ) _| ( / Amazon Linux AMI ___|___|___| https://aws.amazon.com/amazon-linux-ami/2013.03-release-notes/ $ sudo vi /etc/yum.repos.d/td.repo --- [treasuredata] name=TreasureData baseurl=http://packages.treasure-data.com/redhat/$basearch gpgcheck=0
ã¤ã³ã¹ãã¼ã«
$ sudo yum install td-agent -y $ sudo service td-agent start $ sudo chkconfig td-agent on
ãã©ã°ã¤ã³ã®è¿½å
ä»åã¯ãã¿ã°ãåçã«æ±ããã©ã°ã¤ã³ã¨ãã¬ã¼ã¹ãã«ããæ±ããããã«ãããã©ã°ã¤ã³ãã¤ã³ã¹ãã¼ã«ãã¾ãã$ sudo /usr/lib64/fluent/ruby/bin/fluent-gem update $ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-forest $ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-config-expander
権éè¨å®
fluentdã使ã£ã¦åºåãè¡ããå ãã£ã¬ã¯ããªã®æ¨©éãå¤æ´ãã¾ãã$ sudo chgrp td-agent /var/log/httpd/ $ sudo chgrp td-agent /var/log/messages $ sudo chmod g+rx /var/log/httpd/ $ sudo chmod g+rx /var/log/messages
è¨å®
$ sudo vi /etc/td-agent/td-agent.conf --- <source> type config_expander <config> type tail format apache pos_file /tmp/access.log.pos path /var/log/httpd/access_log tag ${hostname}/apache.access </config> </source> <source> type config_expander <config> type tail format /^[[^ ]* (?<time>[^]]*)] [(?<level>[^]]*)] (?<message>.*)$/ time_format %b %d %H:%M:%S pos_file /tmp/error.log.pos path /var/log/httpd/error_log tag ${hostname}/apache.error </config> </source> <source> type config_expander <config> type tail format syslog pos_file /tmp/syslog.pos path /var/log/messages tag ${hostname}/syslog.messages </config> </source> <match *.**> type forest subtype s3 <template> aws_key_id ã¢ã¯ã»ã¹ãã¼ID aws_sec_key ã·ã¼ã¯ã¬ãããã¼ s3_bucket ãã±ããå s3_endpoint s3-ap-northeast-1.amazonaws.com path buffer_path /var/log/td-agent/buffer/${tag} time_slice_format %Y/%m/%d/${tag}/ec2-%Y-%m-%d-%H retry_wait 30s retry_limit 5 flush_interval 1s flush_at_shutdown true </template> </match>
ãã°ã®ç¢ºèª
S3ã確èªããã¨ã以ä¸ã®ããã«ãã°ãåºåããã¦ãã¾ããã ã¾ããS3ã®Directoryããªã¼ã¯ä»¥ä¸ã®ããã«ãªãã¾ããããã±ããå â ââYear â ââMonth ï½ ââDay ï½ ââHostname ï½ ââapache.access â â ââec2-2013-06-19-00_0.gzã»ã»ã» â â ï½ ââapache.error â â ââec2-2013-06-19-00_0.gzã»ã»ã» â â â ââsyslog.messages â ââec2-2013-06-19-00_0.gzã»ã»ã»