Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?
ããã«ã¡ã¯ãЯeiã§ãã ä»åã¯ç¾å½¹ã¨ã³ã¸ãã¢ã§ããç§ãFluent Bitã£ã¦ä½ã ã¨ãã話ã«ã¤ãã¦ã¾ã¨ãããã¨æãã¾ãã æè¿å··ã§è¯ãèãFluent Bitã¨å¼ã°ãããã®ãããã¾ãããããããããã£ã¦ä½ãªã®ã調æ»ãã¾ããã®ã§ã·ã§ã¢è´ãã¾ãã æå¾ã¯docker-composeãç¨ãããµã³ãã«ãç¨æãã¾ããã®ã§è¦ã¦ã¿ã¦ä¸ããã Fluent Bit æ¦è¦ã¯å ¬å¼ãµã¤ãã«åãããããæ¸ããã¦ããã¾ãã®ã§èå³ã®ããæ¹ã¯ä¸èªãã¦ããã¨ããã§ãããã åè fluentbitfluentbit ã¾ããå種ããã¥ã¡ã³ãã¯ä»¥ä¸å ¬å¼è³æã«è©³ããæ¸ããã¦ããã¾ãã®ã§ãã¡ããåèã«ãã¦ããããã°ã¨æãã¾ãã åè Fluent Bit ããã¥ã¡ã³ã æ¦è¦ Fluent Bitã¨ã¯ã ã¢ããªã±ã¼ã·ã§ã³ããåºåããããã°ãã¡ã¤ã«ãæ¨æºåºåãã°ãªã©ã®ãã¼ã¿ãåéãããã£ã«ã¿ãªã³ã°ãã¦è¤æ°ã®å®å ã«éä¿¡ã§ãããã¼ã«ã¨
ããã«ã¡ã¯ãæªã ã«ç«¶é¦¬ã§å½ãã£ããã¨ããªããã·ã¤ã§ãã ä»æ¥ããã¯ã©ã¦ãæ©è½ããæ軽ã«ä½¿ã£ã¦ã¿ãã試ããã¿ãã²ã¨ã¤ãå±ããã¾ãã ãªã³ãã¬ã§ã Cloud Logging ã使ããã⦠ãµã ã GCE ã GKE ã使ã£ã¦ããã¨ãé常ã«ãããªã Cloud Logging ã« log ãå ¥ã£ã¦ãããã®ã§ããªã³ãã¬ãµã¼ãã¼ãæ±ã£ã¦ããã¨ãã«ãããã欲ãããªãã¾ããã¨ãããããªãã§ç¡ããã ï¼ã¨ããæ°æã¡ã«ãªãã¾ãã ãã¨ãã° httpd ã® log ã Cloud Logging ã§è¦ããï¼ã ããªã®ã«ãä¸ç´ç·ã®ãµã³ãã«ãè¦ã¤ãããªãã£ãã®ã§ã¤ãã£ã¦ã¿ã¾ããã container ã§ã試ãã»ãããã¤ãã ãã¤ãæããã§ãããç®çã®æå°æ§æãããã«ç¢ºèªã§ãã container image ãããã¨ä¾¿å©ã ã¨æããã§ãã ã¨ãããã¨ã§ãcontainer ã§ãã£ã¦ã¿ã¾ãã ä»åã¯ãªã³ãã¬ã§ä½¿ã£ã¦ãã
Fluent Bitæ å ± Fluent Bitã¨ã¯ 主ãªç¹å¾´ åä½ç°å¢ Fluent Bitã®ã©ã¤ã»ã³ã¹ åèæ å ± ãªã¼ãã³ã½ã¼ã¹å¹´éãµãã¼ããµã¼ãã¹ Fluent Bitã¨ã¯ Fluent Bit(ãã«ã¨ã³ãããã)ã¯ãCè¨èªã§æ¸ãããã¯ã©ã¦ãåã³ã³ã³ããç°å¢ã«é©ããããã°ã®åéãé å¸ãè¡ããªã¼ãã³ã½ã¼ã¹ã®ãã°ããã»ããµãã¼ã«ã§ãã Fluent Bitã¯Fluentdåä¸ã®CNCFãµãããã¸ã§ã¯ãã§ã2014å¹´ã«çµã¿è¾¼ã¿Linuxãã²ã¼ãã¦ã§ã¤ãªã©ã®å¶ç´ã®ããç°å¢åã軽éãã°ããã»ããµã¨ãã¦Treasure Data社ã®Fluentdãã¼ã ã«ããéçºãããFluentdã¨ã³ã·ã¹ãã ã®ä¸é¨ã¨ãã¦ãFluent Bitã¨åä»ãããã¾ããã 主ãªç¹å¾´ Fluent Bitã¯è»½éã§é«éãããã©ã¼ãã³ã¹ãéè¦ããã¢ã¼ããã¯ãã£ã«ãªã£ã¦ããã以ä¸ã®ãããªç¹å¾´ãããã¾ãã
1[INPUT] 2 Name tail 3 Tag tail.01 4 Path /var/log/system.log 5[OUTPUT] 6 Name s3 7 Match * 8 bucket your-bucket 9 region us-east-1 10 store_dir /home/ec2-user/buffer 11 total_file_size 50M 12 upload_timeout 10m 13[OUTPUT] 14 Name splunk Fluent Bit enables you to collect logs and metrics from multiple sources, enrich them with filters, and distribute them to any defined destination. Optimized data
CloudWatch Logs ã«ä¿åãããã°ã«ç¹å®ã®æè¨ãåºåããã¦ãããéç¥ããæ¹æ³ã調ã¹ã¦ããããCloudWatch Logs ã®ãµãã¹ã¯ãªãã·ã§ã³ãã£ã«ã¿ã¨ããæ©è½ã使ãã°å®ç¾ã§ãããã¨ãåãã£ãã®ã§ãã¡ã¢ã¨ãã¦æ®ãã¦ããããã¨æãã¾ãã æ§æ æ§æã¨ãã¦ã¯ãCloudWatch Logs ã®ãµãã¹ã¯ãªãã·ã§ã³ãã£ã«ã¿ã¨ããæ©è½ã使ãããµãã¹ã¯ãªãã·ã§ã³ãã£ã«ã¿ã§æ¤ç¥ãããã°ã®å 容ã Lambda ã«éããLambda ãã SNS ãããã¯ã«ãããªãã·ã¥ããã¨ããæ§æã«ãªã£ã¦ãã¾ãã ãã°ã°ã«ã¼ããã¨ã«ãæ大ï¼ã¤ã®ãµãã¹ã¯ãªãã·ã§ã³ãã£ã«ã¿ãè¨å®ãããã¨ãã§ããããã§ãã ã¾ããä»åã¯ãLambda ã«éã£ã¦ãã¾ãããAmazon Kinesis ã Amazon KinesisData Firehose ãªã©ã¸éããã¨ãã§ããããã§ãã ãµãã¹ã¯ãªãã·ã§ã³ã使ç¨ãããã°ãã¼ã¿
â ã¯ããã« CloudWatchãSNSãããã¯ãå©ç¨ãã¦ãã°ã«ç¹å®æååãåºåããããã¢ã©ã¼ã çºå ±ããã¡ã¼ã«ãéä¿¡ããã¨ããã¾ã§è©¦ãã«æ§ç¯ãã¦ã¿ãã®ã§æé ãã¾ã¨ãã¾ããã â 対象è æ¬è¨äºã¯AWSåå¦è åãã®æ å ±å ±æã¨ãã¦æ§ç¯æé ãã¾ã¨ãã¦ãã¾ãã ã¾ããèªåç¨ã®æé ã¡ã¢ã§ãããã¾ãã â æ§æå³ EC2ããCloudWatch logsã¸/var/log/messagesãéä¿¡ãç£è¦å¯¾è±¡ã¨ããã CloudWatchã¯"ERROR"æååãæ¤ç¥ããå ´åãã¢ã©ã¼ã çºå ±ããã ã¢ã©ã¼ã çºå ±ããã¨é¢é£ä»ããããSNSãããã¯ã¯æå®ã®å®å ã«ã¡ã¼ã«éç¥ãè¡ãã â ä½æ¥å 容 大ã¾ãã«ä»¥ä¸ã EC2ã«CloudWatchã¨ã¼ã¸ã§ã³ãã®ã¤ã³ã¹ãã¼ã« EC2ã«CloudWatch logsã¸ãã°ãéä¿¡ããããã®æ¨©éãä»ä¸ CloudWatchã¡ããªã¯ã¹ä½æ CloudWatchã¢ã©ã¼ã ä½æ æ¤ç¥ãã¡ã¼ã«é
ã¨ããã°ããããã§ãã ãããã¦ã¿ã GETã®å ´å GET /posts?password=abc123 ãå©ããå ´åãã°ã« Started GET "/posts?password=[FILTERED]" for 127.0.0.1 at 2012-09-20 05:16:44 +0900 Processing by PostsController#index as HTML Parameters: {"password"=>"[FILTERED]"} ã¨URLããã©ã¡ã¼ã¿ã [FILTERED] ã«å¤ãããã¦åºåããã¾ãã POSTã®å ´å POST /posts data: password=abc123 ãå©ããå ´åãã°ã¯ Started POST "/posts" for 127.0.0.1 at 2012-09-20 05:18:12 +0900 Processing by Po
ELBã®ãã«ã¹ãã§ãã¯ãRailsã®ãã°ã«åºããããªãã¦ãRails::Rack::Loggerãç¶æ¿ããRackããã«ã¦ã§ã¢ã§envã®ä¸èº«ãè¦ã¦Rails.logger.silenceããã¿ãããªããã«ã¦ã§ã¢ãä½ããRails::Rack::Loggerã¨swapããã®ã試ãããã§ãããlog_tagsãå¹ããªããªã£ã¦ãã¾ãã¾ããã class CustomRailsRackLogger < Rails::Rack::Logger def call(env) if ['/healthcheck'].include?(env['PATH_INFO']) Rails.logger.silence { super } else super end end end
Railsã¯ä¾¿å©ã æ¬çªãµã¼ãã¹ã稼åããã¦ããæããã«ã¹ãã§ãã¯ãã¹ãªã©ç¹å®ã®ãã¹ã¸ã®ãªã¯ã¨ã¹ãã®ãã°ã¯ãããªãããªãã¦ãã¨ã¯ããããã ALBã使ãã¨ãã«ã¹ãã§ãã¯ã¯å¿ é ã ããZabbixãªã©ã§ãã«ã¹ãã§ãã¯ãçµã¿è¾¼ãå ´åãåæ§ã§ããã ä»åã¯ãç¹å®ã®ãã¹ã«é¢ãããã°ãåºåããªãããã«ããæ¹æ³ã®æ¸ãæºãã ç§ã®å ´åãRailsã®ãã°ãcloudwatch logsã«åºåãã¦ããé½åã 1ç§ã«1åãªã¯ã¨ã¹ãããããã«ã¹ãã§ãã¯ãã¹ã®ãã°ã¯æ£ç´ä¸è¦ã§ãè²»ç¨ããããã ãã ããæ¶ãããã£ãã Rails loggerã§ãã°ãåºåãããªãæ¹æ³ ããæ¹ã¯è²ã ããã ãããã©ãä»åã®æ¹æ³ããã£ããããã¨ãRails::Rack::Loggerãç¶æ¿ããã¯ã©ã¹ãä½æããã Rails.logger.silence ã§ç¹å®ã®ãã¹ãªããã°åºããªããã¼ãã£ã¦ãã£ã¦ããã ãã¹æ å ±ã¯env["REQUEST_P
Ruby2.1.4, Rails4.1.7ã§ç¢ºèªã ELB使ç¨æã«Railsä¸ã«ãã«ã¹ãã§ãã¯ç¨ã®ã¢ã¯ã·ã§ã³ãä½ã£ã¦ãRailsã¢ããªã®ç¶æ ãã§ãã¯ãããããã«ããå ´åãã¢ããªã±ã¼ã·ã§ã³ãã°ã«ãã«ã¹ãã§ãã¯ã®ãã°ãæ®ã£ã¦ãã¾ãã¾ãã ãã«ã¹ãã§ãã¯ç¨ã®ã¢ã¯ã·ã§ã³ãã¤ãããã¨ã«é¢ãã¦ã¯ä»¥åã®è¨äºãåç §ãã ããã [[rails]ELB使ç¨æã«ãã«ã¹ãã§ãã¯ç¨ã®ã¢ã¯ã·ã§ã³ãä½æãã](http://blog.hello-world.jp.net/ruby/2104/)ä¸è¨è¨äºã«æ²¿ã£ã¦ã¢ã¯ã·ã§ã³ãä½æããå ´åã¯ã以ä¸ã®ããã« /health ã¸ã®ã¢ã¯ã»ã¹ãã¢ããªã±ã¼ã·ã§ã³ãã°ã«è¨é²ããã¾ãã # log/production.log I, [2014-12-15T19:59:54.149846 #7459] INFO -- : Started GET "/health" for 127.0.0.
ã«ããã±ãã¼ ãã¼ããã©ã³ãµã®ãã«ã¹ãã§ãã¯ã§ log/production.log ãåãå°½ããããã®ãè¾ãã®ã§ãç¹å®ã®æ¡ä»¶ã§ãã°åºåãææ¢ããæ¹æ³ã調ã¹ããã ãã¬ã¼ã¯ã©ã¹ãä½æãã ã¾ããRails::Rack::Loggerãç¶æ¿ããCustomLoggerãä½æããã class CustomLogger < Rails::Rack::Logger def call(env) if env["REMOTE_ADDR"] =~ Moe::Application.config.action_dispatch.trusted_proxies and !env["HTTP_X_FORWARDED_FOR"] Rails.logger.silence do super end else super end end end ããã§ã¯ããã¼ããã©ã³ãµã®IPã¢ãã¬ã¹ã¯trusted_proxie
ãçµè«ã scriptã³ãã³ãã§ã¿ã¼ããã«æä½ããã°ã«æ®ããã dateã³ãã³ãã§ã¿ã¤ã ã¹ã¿ã³ããåå¾ã§ããã ã¿ã¼ããã«ã«ã¯ãèµ·åæã«ã³ãã³ããèªåå®è¡ããæ©è½ãããã ä¸è¨3ã¤ãç¨ãããã¨ã§ãã¿ã¼ããã«æä½ã®ãã°ãèªåã§æ®ããã ãã ããMacæ¨æºã®scriptã³ãã³ãã¯-f(å³æåæ )é対å¿ãªã®ã§ãããã¢ã¤ã³ã³ã§ã¿ã¼ããã«çµäºããã¨ãã°ãæ®ããªãã®ã§ä½¿ãã¥ããã ãç®æ¬¡ã ã¿ã¼ããã«æä½ããã¡ã¤ã«ã«æ®ãæ¹æ³ ã¿ã¤ã ã¹ã¿ã³ããåå¾ããæ¹æ³ ã¿ã¼ããã«èµ·åæã«ã³ãã³ããå®è¡ããæ¹æ³ ãã°ãä¿åããããã®ã³ãã³ãã®ä¾ ãã¾ã åèæ å ± æå¾ã« ã¿ã¼ããã«æä½ããã¡ã¤ã«ã«æ®ãæ¹æ³ scriptã³ãã³ããå®è¡ãããã¨ã§ã以éã®ã¿ã¼ããã«æä½ããã¡ã¤ã«ã«æ®ããã¨ãã§ãã¾ãã $ script "ãã¡ã¤ã«å" æ¸ãåºãä¸ã¯bash-3.2$ã¨è¡¨ç¤ºããã¾ãã(â»1) æ¸ãåºãä¸ã«exitã³ãã³ãå®è¡
Logrotate ã®æ£ä½ã¯ã³ãã³ã㨠cronãã°ãã¼ãã¼ãã¨ã¯ããã°ãã¡ã¤ã«ã®ãµã¤ãºã大ãããªããªãããã«ã1 æ¥ãã¾ã㯠1 é±ãã¾ã㯠1 ãæã¨ãã£ãæéã§ãã¡ã¤ã«åãå¤æ´ããè¨å®æ¬¡ç¬¬ã§ã¯å¤ããã¡ã¤ã«ã gzip ã§å§ç¸®ãããããã£ã¨å¤ããã¡ã¤ã«ãåé¤ããããããã¨ãã§ããä»çµã¿ã®ãã¨ã§ãã Logrotate ã¯ãã¼ã¢ã³ã¨ãã¦åä½ãã¦ããã¨åéãããããã¨ãå¤ãããã§ããããã®å®ä½ã¯ /usr/sbin/logrotate ã¨ããã³ãã³ã㨠cron.daily ã®çµåãã§ããã¤ã¾ããcrond ã«ãã£ã¦logrotate ã³ãã³ããæ¯æ¥å®è¡ããã¦ããã®ã§ãã Logrotate ã® Statusãªãã以ä¸ã® cron è¨å®ãè¦ãã°åããéããlogrotate ã³ãã³ãã«ã¯å¼æ°ã¨ãã¦ãååã®å®è¡æå»ããä¿åãã logrotate.status ã¨ãè¨å®ãã¡ã¤ã«ãã§ãã lo
ç®æ¬¡ 1. æ§ç¯è¦ä»¶ 2. logrotate 㨠cron ã®ã¤ã³ã¹ãã¼ã« 2.1 logrotate ã®ã¤ã³ã¹ãã¼ã« 2.2 cron ã®ã¤ã³ã¹ãã¼ã« 3. cron ã¸ã§ã㧠logrotate ã®å®è¡è¨å® 3.1 crontab ã®è¨å® 3.2 /etc/cron.weekly ã®è¨å® 3.3 ãã°ãã¼ãã¼ã·ã§ã³ã®è¨å®ãã¡ã¤ã« /etc/logrotate.conf ã®è¨å® 3.4 cronãµã¼ãã¹ã®åèµ·å 4.ãã°ãã¼ãã¼ã·ã§ã³ã®åä½ç¢ºèª 1. æ§ç¯è¦ä»¶ /opt/aem/author/crx-quickstart/logs é ä¸ã®ãã°ãã¡ã¤ã« stdout.log ããã£ã¨ãµã¤ãºãå¢ãã¦ãããããå®æçã«ãã°ãã¼ãã¼ã·ã§ã³ããæ¹æ³ãç´¹ä»ãã¾ãã å®è¡é »åº¦ï¼æ¯æ¥ 02:00 ã«å®è¡ãã¾ãã å®è¡å 容ï¼ãã®ï¼ï¼ï¼ãã°ãã¡ã¤ã«ãåæ¥ã®æ¥ä»ä»ãã¦ãªãã¼ã ãã¾ããï¼ä¾ï¼stdout.lo
Certbotã§åå¾ããSSL/TLS証ææ¸ã®æ´æ°ãèªååãã¦ãã¾ããã ããããã®ã¤ããã ã£ãã®ã§ãããcronããã¾ãå®è¡ãã¦ããªããã¨ã«æ°ã¥ããããã調æ»ãããã¨ã«ãã¾ããã ã¨ããããã§cronã¸ã§ãã®ãã°èª¿æ»æ¹æ³ã«ã¤ãã¦ã¡ã¢ãã¾ãã cronã®å®è¡ç¶æ³ã®ç¢ºèªcronã§æå®ããã¸ã§ããå®è¡ããã¦ããã確èªããã«ã¯ã /var/log/ é ä¸ã«ãã cron ãã¡ã¤ã«ãè¦ã¾ãã less /var/log/cron ããããã®ãã¡ã¤ã«ã«ã¯å®è¡ãã°ããæ®ã£ã¦ãã¾ããã ã¸ã§ãã®å®è¡çµæã確èªããã«ã¯å¥éãã¡ã¤ã«ã«åºåãããããè¨å®ããå¿ è¦ãããã¾ãã cronã®å®è¡çµæãä¿åããæ¹æ³cronã§è¨å®ããã¸ã§ãã®å®è¡çµæããæå®ãããã¡ã¤ã«åã§åºåããã¾ãã crontab -e ã§éãã次ã®ãããªæãã§è¨å®ãã¾ãã 0 * * * * /usr/local/bin/myjob > /va
ã¢ããªã±ã¼ã·ã§ã³ã«ã¨ã£ã¦ãã°ãã¡ã¤ã«ã¯ã¤ãã³ããã¨ã©ã¼ãªã©ãè¨é²ãã¦ããéè¦ãªãã¡ã¤ã«ã§ããããããåããã¡ã¤ã«ã«ãã°ãæ¸ãè¾¼ã¿ç¶ãã¦ããã¨ãã°ãã¡ã¤ã«ã¯ã©ãã©ãè¥å¤§åãã¦ãããã¨ã«ãªãã¾ãã ãã°ãè¥å¤§åããã¨æ¬¡ã®ãããªä¸é½åãããã¾ãã ãã£ã¹ã¯é åãå§è¿«ãã ãã°ã確èªããã¨ãããã¡ã¤ã«ãèªã¿è¾¼ãã®ãç¹å®ã®å ´æãæ¢ãã®ãå¤§å¤ ãã®ãããã°ãã¡ã¤ã«ãè¥å¤§åããªãããã«é©åãªãã°ã®ãã¼ãã¼ã·ã§ã³ãå¿ è¦ã§ãã Linuxã§ã¯ã·ã¹ãã ã«ããå¤ãã®ãã°ãã¡ã¤ã«ããã¼ãã¼ãããããã«è¨è¨ãããlogrotateããã°ã©ã ï¼ã³ãã³ãï¼ãç¨æããã¦ãã¾ãã ãã®è¨äºã§ã¯Linuxã§logrotateãã©ã®ããã«è¨å®ãã使ããã¦ããã®ãããã®ä»çµã¿ãç´è§£ãã¦ããã¾ãã ãªãlogrotateã«ã¤ãã¦ã¯ãlogrotateã®ãã¹ãæ¹æ³ãã¨ããè¨äºãæ¸ãã¾ããã®ã§åç §ããã ããã¨å¹¸ãã§ãã logrota
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}