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

Consul KV Dashboard

Consul KV Dashboard

monitoring casual #7

FUJIWARA Shunichiro

January 30, 2015
Tweet

More Decks by FUJIWARA Shunichiro

Other Decks in Programming

Transcript

  1. IRCʹ௨஌͠Α͏ parallel, cap, ... ͷग़ྗ݁ՌΛ… ࣾ಺༻ nopaste-cli command $ cat

    foo.log | nopaste-cli -channel "hoge" -summary "foo done!" nopasteʹPOSTͱಉ࣌ʹIRCʹURL͕௨஌͞ΕΔ શ୆෼·ͱΊΔͱࣦࠞͬͯ͡ഊͨ͠ͷ͕෼͔ΓͮΒ͍ ؅ཧϗετ͔ΒpushͰͳ͍ܗଶ(consul event)Ͱ͸औಘͰ͖ͳ͍
  2. Consul KV Dashboard Consul KVS ΛσʔλετΞʹͨ͠ϦΞϧλΠϜμογϡϘʔυ Πϕϯτ಺༰Λ Consul REST API

    Ͱอଘ ͦΕΛ͍͍ײ͡ʹݟͤͯ͘ΕΔ wep application Go (API Server) + React.js (View) [Demo]
  3. σʔλొ࿥ Consul REST APIͰ௚઀ૹΔ $ curl -X PUT -d "message"

    \ localhost:8500/v1/kv/dashboard/example/myhostname?flags=1422607461000
  4. keyߏ଄ /v1/kv/dashboard/{category}/{nodename}? flags={timestamp * 1000 + status} • category: chef,

    serverspec, deploy... • nodename: ConsulͰࣝผ͍ͯ͠Δϊʔυ໊ • flags: ࣌ࠁͷunix time * 1000 + status • status: 0=success 1=warning 2=danger 3=info
  5. ϦΞϧλΠϜߋ৽ͷ࣮ݱํ๏ ConsulͷϒϩοΩϯάΫΤϦΛ࢖͏ www.consul.io/docs/agent/http.html $ curl -i localhost:8500/v1/kv/dashboard/chef/myhost?recurese HTTP/1.1 200 OK

    Content-Type: application/json X-Consul-Index: 261975 [{"CreateIndex":261891,"ModifyIndex":261975,"LockIndex":0, "Key":"dashboard/chef/myhost","Flags":1422602855000,"Value":".....
  6. ϒϩοΩϯάΫΤϦ Ϩεϙϯεϔομͷ X-Consul-Index Λ index ʹࢦఆ͢Δ $ curl -i localhost:8500/v1/kv/dashboard/chef/myhost?index=261975

    indexΑΓ৽͍͠σʔλ͕ൃੜ͢Δ·ͰϨεϙϯε͕஗Ԇ ৽͍͠σʔλ͕ൃੜ͢ΔͱϨεϙϯε͕ฦΔ ͍ΘΏΔ Long pooling
  7. consul-kv-dashboard ͕΍Δ͜ͱ Consul REST API ΁ͷ proxy • /api/... →

    localhost:8500/v1/kv/dashboard/... • ϨεϙϯεͷJSONΛΫϥΠΞϯτ͕ѻ͍΍͍͢Α͏ʹ੔ܗ • {"Flags":1422608524001} → {"timestamp":"2015-01-30 18:02:04 +0900","status":"warning"} View ͸ React.js