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

consul-atlas-alerts

rrreeeyyy
August 05, 2015

 consul-atlas-alerts

#hashi_wantedly

rrreeeyyy

August 05, 2015
Tweet

More Decks by rrreeeyyy

Other Decks in Technology

Transcript

  1. Hashicorp*ͱΘͨ͠(ͱձࣾ) • h#ps:/ /speakerdeck.com/rrreeeyyy/hashicorp3tools3overview • Vagrant;→;(΄΅ΈΜͳ࢖ͬͯΔ) • Packer;→;(࢖ͬͯͳ͍) • Serf;→;(࢖ͬͯͳ͍)

    • Consul;→;(࢖ͬͯΔҊ͕݅;1;ͭ͋Δ/ࣗ෼͕৮ͬͯΔ/ଞʹ΋৮ͬͯΔਓ͕͍Δ) • Terraform;→;(࢖͍͍ͨ/ݕূͯ͠Δਓ΋ࣗ෼Ҏ֎ʹډΔ) • Vault;→;(Θ͕ͨ͠৮ͬͯΔ) !Hashicorp!meetup!2015/08/05!5!Yoshikawa!Ryota!(!@rrreeeyyy!)! 3
  2. લճ·Ͱͷ͋Β͢͡!1 • consul(ͷ(health-check(3(͕ࣦഊͨ͠Β(Pagerduty/Slack/Hipchat/ email...(ʹΞϥʔτൃใ • consul-alert(Λ࢖࣮ͬͯݱ • Nagios/Sensu(ͷεΫϦϓτΛྲྀ༻ͯ͠ઃఆՄೳ • HTTP(API(͔Β؂ࢹ/αʔϏεొ࿥͕ग़དྷͯศར

    3"h$p:/ /www.consul.io/docs/agent/checks.html 1"h$p:/ /www.slideshare.net/rrreeeyyy117/consul8andalertsmonitoring !Hashicorp!meetup!2015/08/05!5!Yoshikawa!Ryota!(!@rrreeeyyy!)! 5
  3. Atlas • ࠷ۙ(7$݄಄ࠒ)Ұൠ޲͚ϦϦʔε͞Εͨ$4 • Hashicorp$֤πʔϧͱͷ࿈ܞ͢ΔϓϥοτϑΥʔϜ • ΋ͪΖΜ$Consul$࿈ܞ΋͋Δ • લड़ͷΞϥʔτγεςϜ΋$Atlas$Λ࢖͑͹ग़དྷΔ •

    Consul$+$Atlas$͚ͩͰՄೳ 4"h$ps:/ /hashicorp.com/blog/atlas4general4availability.html !Hashicorp!meetup!2015/08/05!5!Yoshikawa!Ryota!(!@rrreeeyyy!)! 6
  4. Atlas&+&Consul • /etc/consul.conf { "server": true, "node_name": "NODE-NAME", "datacenter": "DC-NAME",

    "data_dir": "/usr/local/consul/data", "bind_addr": "192.168.2.1", "bootstrap_expect": 3, "addresses": { "http": "192.168.2.1" }, "log_level": "INFO", "atlas_token": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "atlas_join": true, "atlas_infrastructure": "topotal/groupname" } !Hashicorp!meetup!2015/08/05!5!Yoshikawa!Ryota!(!@rrreeeyyy!)! 7
  5. Atlas&+&Consul • consul.service : [Service] User=consul Group=consul ExecStart=/usr/local/bin/consul agent -config-file

    /etc/consul.conf ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=10s : !Hashicorp!meetup!2015/08/05!5!Yoshikawa!Ryota!(!@rrreeeyyy!)! 8
  6. ىಈ࣌ʹ!json!Λ౉ͯ͠ొ࿥ • ࣍ͷΑ͏ͳ"json"Λىಈ࣌ʹ౉ͯ͋͛͠Δ • -config-file"΋͘͠͸"-config-dir { "service": { "id": "linux-server",

    "name": "linux-server", "tags": ["linux-server"] } } { "check": { "id": "check_load", "name": "Load Average", "script": "/usr/lib64/nagios/plugins/check_load -w 15,12,12 -c 30,25,20", "interval": "30s", "service_id": "linux-server" } } !Hashicorp!meetup!2015/08/05!5!Yoshikawa!Ryota!(!@rrreeeyyy!)! 11
  7. ىಈ࣌ʹ!json!Λ౉ͯ͠ొ࿥ • config-dir"͸σΟϨΫτϦΛ࠶ؼతʹಡ·ͳ͍ • -config-dir /etc/consul.d/"Λࢦఆͨ͠৔߹ • -config-dir /etc/consul.d/*.json"ΛΞϧϑΝϕοτॱͰಡΉ •

    /etc/consul.d/role/*.json"͸ಡ·ͳ͍ • ಉ͡σΟϨΫτϦʹ"Service/Check"༻ͷ"json"Λஔ͔ͳ͍ํ͕ྑ͍ • ઌʹ"Service"༻ͷ"json"͕ಡ·Εͳ͍ͱىಈ࣌ʹࢮ͵ !Hashicorp!meetup!2015/08/05!5!Yoshikawa!Ryota!(!@rrreeeyyy!)! 12
  8. HTTP$API$ӽ͠Ͱొ࿥ • ࣍ͷΑ͏ʹͯ͠౤͛Δ • json"ͷॻ͕ࣜىಈ࣌ʹ౉͢΋ͷͱ͸ҧ͏ͷͰ஫ҙ͢Δ [root@localhost ~]# cat load.json {

    "id": "check_load", "name": "Load Average", "script": "/usr/lib64/nagios/plugins/check_load -w 15,12,12 -c 30,25,20", "interval": "30s", "service_id": "linux-server" } [root@localhost ~]# curl -vvv -X PUT -d \ > @disk_root.json http://192.168.2.1:8500/v1/agent/check/register !Hashicorp!meetup!2015/08/05!5!Yoshikawa!Ryota!(!@rrreeeyyy!)! 13
  9. ·ͱΊ • ࠓճ͸"Consul"+"Atlas"ͰΞϥʔτγεςϜΛ࡞ͬͨ • consul-alerts"ͷ͜ͱΛߟ͑ͳͯ͘ྑ͘ͳΔͷͰָ • Ϋϥελͷॳظߏஙָ͕ʹͳΔ • Atlas"͸"10"୆͙Β͍·Ͱ͸ແྉʂ •

    ݸਓن໛Ͱ"Nagios/Zabbix"ཱͯͨ͘ͳ͍ͬͯਓʹ͸Φεεϝ • ֎ܗ؂ࢹΈ͍ͨͳͷ͸ผ్ߟ͑Δඞཁ͕͋Γͦ͏ • Pingdom"ͱ͔ʁ • ຊ౰͸"Mackerel"΍"Datadog"ͱ૊Έ߹Θ͍ͤͨͳʙ !Hashicorp!meetup!2015/08/05!5!Yoshikawa!Ryota!(!@rrreeeyyy!)! 19