Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mackerel - Current status #mackerelio

Shinji Tanaka
September 24, 2014

Mackerel - Current status #mackerelio

Mackerel Meetup #2
Sep 24, 2014

Shinji Tanaka

September 24, 2014
Tweet

More Decks by Shinji Tanaka

Other Decks in Technology

Transcript

  1. • Go Ͱॻ͔ΕͨެࣜΤʔδΣϯτ • Linux αϙʔτ (CentOS 5/6, Debian 6/7)

    • ϗετεϖοΫͱϝτϦοΫΛऩू mackerelio/mackerel-agent mackerel-agent
  2. αʔϏεͱϩʔϧ • αʔϏε • ͞·͟·ͳϗετ͕ڠௐ • Hatena-Bookmark, Hatena-Blog, … •

    ϗετ܈Λ໾ׂͰ·ͱΊΔ = ϩʔϧ • app, db, … IFMQKBNBDLFSFMJPFOUSZIPXUPDSFBUFTFSWJDFTBOESPMFT
  3. αʔϏε - ϩʔϧ • Hatena-Blog • app • host01, host02,

    … • db • memcached • Hatena-Bookmark • app • crawler
  4. ChefͰηοτΞοϓ͢Δ • cookbook-mackerel-agent • mackerelio/cookbook-mackerel-agent #  APIΩʔΛઃఆ   node.default['mackerel-­‐agent']['apikey']  =

     <API  KEY>   #  αʔϏεɾϩʔϧΛࢦఆ   node.default['mackerel-­‐agent']['conf']['roles']  =  ["My-­‐Service:app",   “Another-­‐Service:db"]   #  ϓϥάΠϯΛࢦఆ   node.default['mackerel-­‐agent']['conf']['plugin.metrics.vmstat']  =  {      'command'  =>  'ruby  /etc/sensu/plugins/system/vmstat-­‐metrics.rb',   }   ! include_recipe  'mackerel-­‐agent'
  5. agent: ϝτϦοΫऩू • ϗετͷϦιʔεͷ࣌ࠁ͝ͱͷ਺஋ • ඪ४: loadavg5, cpu.*, memory.*, interface.*,

    disk.* • ΧελϜ: ֤छϛυϧ΢ΣΞରԠϓϥάΠϯ • αʔϏεϝτϦοΫ • Ԡ౴࣌ؒɾΤϥʔ཰ɾΞΫςΟϒϢʔβʔ਺
  6. agent: ΧελϜϝτϦοΫ • plugin.metrics.*.command Λهड़ # mackerel-agent.conf [plugin.metrics.my-super-metric] command =

    “/path/to/my-super-metric.sh” IFMQKBNBDLFSFMJPFOUSZBEWBODFEDVTUPNNFUSJDT
  7. ΧελϜϝτϦοΫͷऔಘ • mackerel-agent-plugins • MackerelͷެࣜϓϥάΠϯू •        mackerelio/mackerel-­‐agent-­‐plugins

      • ࠷৽(0.4.0): apache2, memcached, mysql, nginx, plack, postgres, redis • ࣍ϦϦʔε: haproxy, jvm, squid, varnish
  8. ྫ: NginxͷΞΫηεϩά͔Β
 εςʔλείʔυ͝ͱʹΧ΢ϯτ #1 • tail plugin #  LTSVܗࣜͷϩάϑΝΠϧΛಡΈࠐΉ  

    <source>      type  tail      format  ltsv      time_format  %d/%b/%Y:%H:%M:%S  %z      path  /var/log/nginx/access.log      pos_file  /var/log/nginx/access_log.pos      tag  access.nginx   </source>
  9. ྫ: NginxͷΞΫηεϩά͔Β
 εςʔλείʔυ͝ͱʹΧ΢ϯτ #2 • fluent-plugin-datacounter #  fluent-­‐plugin-­‐datacounterͰεςʔλείʔυผʹूܭ͢Δ   <match

     access.nginx>      type  datacounter      count_interval  1m      count_key  status      aggregate  all      tag  nginx.status      pattern1  2xx  ^2\d\d$      pattern2  3xx  ^3\d\d$      pattern3  4xx  ^4\d\d$      pattern4  5xx  ^5\d\d$   </match>
  10. ྫ: NginxͷΞΫηεϩά͔Β
 εςʔλείʔυ͝ͱʹΧ΢ϯτ #3 • fluent-plugin-mackerel #  fluent-­‐plugin-­‐mackerelʹΑΓαʔϏεϝτϦοΫΛ౤ߘ͢Δ   <match

     nginx.status.**>      type  mackerel      api_key  <౤ߘઌΦʔΨχθʔγϣϯͷAPIΩʔ>      service  <౤ߘઌαʔϏε໊>      metrics_name  access_num.${out_key}      out_keys  2xx_count,3xx_count,4xx_count,5xx_count   </match>
  11. mackerel-client gem rubygems.org/gems/mackerel-client hosts  =  client.get_hosts(     :service  =>

     'Hatena-­‐Blog',     :roles  =>  'proxy'   )   ! client.update_host_status     host_id,  'working'  
  12. mkr: CLI Mackerel Client • mkr host info --service Hatena-Blog

    --role proxy! • mkr host status —host-id <host_id> —status working
  13. Capistrano ࿈ܞ • config/deployͷMackerel APIͱͷ࿈ ܞΛهड़ → ৄࡉ͸ϔϧϓ΁ #  bundle

     exec  cap  deploy:echo      *  2014-­‐09-­‐23  21:36:28  executing  `deploy:echo'      *  executing  "echo  \"Integration  Test\""          servers:  ["127.0.0.1"]          [127.0.0.1]  executing  command    **  [out  ::  127.0.0.1]  Integration  Test          command  finished  in  435ms IFMQKBNBDLFSFMJPFOUSZBEWBODFEDBQJTUSBOPY
  14. Pricing • Standard • 2,000ԁ/ϗετɾ݄ • ϗετ୆਺ 20+ ͰϘϦϡʔϜσΟεΧ΢ϯτ •

    ແྉτϥΠΞϧ͋Γ • Free • 5୆·Ͱ • දࣔظؒ(24h)ɺαʔϏεϝτϦοΫ਺ɾ؂ࢹ਺ʹ੍ݶ