å é±ãã¨ãã¨ã Mackerel ã«ã°ã©ãã¢ããã¼ã·ã§ã³æ©è½ããªãªã¼ã¹ããã¾ããã
ãã®æ©è½ã使ãã°ãããããã¤å®æ½ãã¨ããããã«ã¦ã§ã¢ã®è¨å®ãå¤æ´ããªã©ã¨ãã£ããªãã¬ã¼ã·ã§ã³ã®å®æ½ã®è¨é²ã«å ãã¦ããçµé¨å¤2åãã£ã³ãã¼ã³éå§ããCMæ¾æ ã¹ã¿ã¼ããã¨ãã£ããã¸ãã¹æ½çã¨ãã¦ã®ã¤ãã³ãã®æ稿ãã§ããããã«ãªãã¾ãããããã®ã¤ãã³ãã®ä»¥åã»ä»¥å¾ãã¨ãã£ãã°ã©ãã®è¦æ¹ããããããªãã®ã§ãããã¯ä¾¿å©ï¼ï¼
"Mackerel ãªã¿ã¯" ãèªç§°ãã¦ãã身ï¼åèï¼ã¨ãã¦ã¯ã¹ã«ã¼ã§ããªãã¯ã¯ã¯ã¯æ©è½ï¼ã¨ãããã¨ã§ãæ©éèªåã®ã¢ããªã±ã¼ã·ã§ã³ã«ãçµã¿è¾¼ãã§ã¿ããã¨ã«ãã¾ããã
capistrano ã®ãããã¤ã¿ã¹ã¯ã«ã°ã©ãã¢ããã¼ã·ã§ã³ã® POST ãçµã¿è¾¼ã
ä»åã¯ã¨ããããã®ã試ãã¨ãããã¨ã§ãcapistrano ã®ãããã¤ã¿ã¹ã¯ã®ãã¡ deploy:starting
ã§ãããã¤éå§æéã®ã»ãããè¡ãã deploy:finished
ã§çµäºæéã®åå¾ãå«ããã¢ããã¼ã·ã§ã³æ
å ±ã®ä½æ㨠POST ã®å®è¡ãè¡ã£ã¦ã¿ãã
ããããããã¨ã«ãmackerel-client-ruby gem ãæ¢ã«ã°ã©ãã¢ããã¼ã·ã§ã³ã«å¯¾å¿ãã¦ããã¦ããã®ã§ãä»åãããã使ããã¨ã«ããã
Gemfile ã«è¿½å ã㦠bundle install
ãcapistrano ã§æ±ãããããCapfile ã« require ã追å ããã
require 'mackerel'
Mackerel ã¸ã®æ稿ã¯æ¬çªãã¹ãã¸ã®ãããã¤ãè¡ã£ãã¨ãã®ã¿å®è¡ãã¦ã»ããã®ã§ã config/deploy/production.rb
ã«ä»¥ä¸ã®ãããªè¨è¿°ã追å ã
namespace :deploy do # Mackerel ã®ã°ã©ãã¢ããã¼ã·ã§ã³ã®ããã«ãããã¤éå§æéãåå¾ããã ãã®ã¿ã¹ã¯ task :starting do set :deploy_starttime, Time.now.to_i end task :finished do deploy_endtime = Time.now.to_i annotation = { service: 'home_a-know_me', role: [ 'web' ], from: fetch(:deploy_starttime), to: deploy_endtime, title: 'Application Deployed', description: 'Application deployed by capistrano' } mackerel_client = Mackerel::Client.new(mackerel_api_key: ENV['MACKEREL_APIKEY']) mackerel_client.post_graph_annotation(annotation) end end
API ãªã¯ã¨ã¹ãã«å¿ è¦ãª API ãã¼ã¯ãä½ããã®æ段ã«ããç°å¢å¤æ°ã«ã»ãããã¦ãããã®ã¨ããããã®ä»ãã ãã¶é©å½ã«æ¸ãã¦ããã®ã§ããä»äºã§ä½¿ãå ´åãªã©ã«ã¯ããå°ãæ°ãé£ã£ã¦ããããã°ã¨æãã
ä¸è¨ã®å®è¡çµæãâããã
楽åããã pic.twitter.com/CsljwydJCs
— a-know (@a_know) 2017å¹´1æ29æ¥
ã»ã»ã»è¯ãï¼ï¼
åã®ãã®ãªãã¸ããªã§ã¯ãmaster ãã©ã³ãã«ãã¼ã¸ããã¿ã¤ãã³ã°ã§ CircleCI ãããããã¤ãè¡ãªãããã«ãã¦ããï¼ãããæåã§ã¯è¡ããªãããã«ãã¦ããï¼ãã ãã©ããã®ã¿ã¤ãã³ã°ã§ããã¡ããã¡ããã¨ã¢ããã¼ã·ã§ã³ã®æ稿ã¯è¡ãããã
ä»åã¯ã¢ããªã±ã¼ã·ã§ã³ã®ãããã¤ã¿ã¤ãã³ã°ã§ã®ã¢ããã¼ã·ã§ã³æ稿ã«ã¨ã©ã¾ã£ã¦ãã¾ã£ããã©ãChef ã«ãããããã¸ã§ãã³ã°ãè¡ã£ã¦ããã®ã§ãã®ã¿ã¤ãã³ã°ã§ããã¢ããã¼ã·ã§ã³æ稿ãããããã«ãããã¨æãã
以ä¸ã® p-r ããä»åã®ä½æ¥ãè¡ã£ããã®ãªã®ã§ããããããã°åããã¦ã©ããã