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

Spring Boot Adminことはじめ / Introduction of Spring...

Spring Boot Adminことはじめ / Introduction of Spring Boot Admin

LINE Developers

March 25, 2019
Tweet

More Decks by LINE Developers

Other Decks in Technology

Transcript

  1. ֤ίϯϙʔωϯτ΋छྨ͝ͱʹ ٕज़ελοΫ΋ҧ͍ͬͯͨ ϦϦʔε౰ॳ WAF Ҡߦޙ core Avans Spring Boot 2.1.3

    ؅ཧը໘ Spring 4.3.x Spring Boot 2.2.x (༧ఆ) chat Spring Boot 1.4.x Spring Boot 2.2.x (༧ఆ) for LINE Bot Spring Boot 1.5.x Spring Boot 2.1.3 ։ൃνʔϜ͕एׯ෼͔Ε͍ͯͨɺͱ͔͍͏Α͋͘Δཧ༝ɻ
  2. • γεςϜϝτϦΫε • Grafana • Kibana • Ξϥʔτ௨஌ • IMON

    (https://www.slideshare.net/linecorp/observability-at-line) • Prometheus • ϩά؂ࢹ • IMON • Kibana • ϓϩϑΝΠϦϯά • VisualVM, Java Flight Recorder, jstack, etc ֤छπʔϧ
  3. • ద੾ͳόʔδϣϯͷΞϓϦέʔγϣϯ͕σϓϩΠ͞ΕͯΔ͔஌Γ͍ͨ • JVM ͕ద੾ʹՔಇ͍ͯ͠Δ͔ΛϦΞϧλΠϜʹݟ͍ͨ • ద੾ͳઃఆͰΞϓϦέʔγϣϯ͕Քಇ͍ͯ͠Δ͔Λݟ͍ͨ • CPU/Memory αϯϓϦϯά

    (Spring Boot Admin Ͱ͸ݱঢ়Ͱ͖ͳ͍) • αʔό਺ଟΊͳͷͰɺઃఆϑϦʔͩͱେ׻ܴ • ίετͷ͜ͱΛߟ͑ΔͱɺαʔόΛݮΒͨ࣌͠΋ָ͍ͨ͠ • ͜ΕΒͷ৘ใΛαʔϏεʹར༻͍ͯ͠ΔαʔόΠϯελϯεશͯͰҰݩ؅ཧͰ͖ ΔμογϡϘʔυతͳ΋ͷ ཉ͔ͬͨ͠΋ͷ
  4. • ಋೖ͕؆୯ • Actuator ͰऔಘͰ͖Δ৘ใΛ Web UI Ͱදࣔ͢Δ • Πϯελϯεͷ

    Up/Down ͷΠϕϯτൃੜ࣌ʹ Slack ͳͲͰ௨஌͢Δ͜ͱ͕Մೳ • ࣗલͷ௨஌खஈ΋࣮૷ʹΑΓՄೳ • ೝূͷ࢓૊Έ͸ͳ͍͕ Spring Boot Security Λར༻͢ΔͳͲͯ͠ಋೖՄೳ • Hazelcast Λར༻ͨ͠ΫϥελϦϯά • ಋೖͷࢀߟʹͳΔαϯϓϧ͕๛෋ Spring Boot Admin ͷಛ௃
  5. Spring Boot Admin શମߏ੒ Application With SBA Client Spring Boot

    Admin Server Web Browser Application With SBA Client Application With SBA Client Registration Show Instances Fetch Actuators Fetch Actuators (Proxy)
  6. Spring Boot Admin Server ͷ࢓૊Έ Application With SBA Client •

    @EnableAdminServer ΞϊςʔγϣϯΛ͚ͭΔ͜ͱͰ AdminServerMarkerConfiguration.Marker (ҎԼ Marker) ͕ Bean ొ࿥͞ΕΔ • ݁Ռతʹ AdminServerAutoConfiguration ͕༗ޮ͔͞Ε SBA ͷΞϓϦέʔγϣϯ ͕࣮ߦ͞ΕΔ • Client ͔Βͷొ࿥Λ /instances ʹ POST ͞ΕΔ͜ͱͰड͚෇͚Δ • ड͚෇͚ͨσʔλΛ InMemory ͔ Hazelcast ʹอଘ • Event Journal ͰҰཡදࣔͯ͠Δ • Web UI ͕ /instances/{instanceId}/actuator/** ͷϦΫΤετΛड͚ͨΒɺԼهͷΑ ͏ʹ proxy ͢Δ Spring Boot Admin Server Web Browser
  7. Spring Boot Admin Client ͷ࢓૊Έ • spring.factories ͷதͰ SpringBootAdminClientAutoConfiguration ΛಡΈࠐΜͰΔ

    • ͦͷதͰ RegistrationApplicationListener ͷ Bean Λ࡞ͬͯ • ThreadPoolTaskScheduler Λ࢖ͬͯఆظతʹ ApplicationRegistrator#register Λ࣮ ߦͯ͠ Server ͷ API Λୟ͍ͯɺΞϓϦέʔγϣϯొ࿥Λߦ͍ͬͯΔ
  8. • http trace ͸ session ΍ header ͳͲ͸ɺશ෦ OFF ʹ͢Δ

    • ෆඞཁʹ Actuator ͸ղ์͠ͳ͍ management ͷઃఆʹؾΛ࢖͏
  9. • ͦͷ··ͩͱ CSRF ੬ऑੑ͕͋ΔͷͰɺͪΌΜͱ SecurityConfig ౳Λ࣮૷͢Δ • Ͳͷϗετ͔ΒͰ΋Πϯελϯεͷొ࿥Ͱ͖ͨΓ Admin ͷ

    Web Λར༻͢Δͷ΋ ؅ཧ͕Ͱ͖ͳ͘ͳΔͷͰ Spring Boot Security ͳͲͰ࠷௿ݶͷೝূ͔͚Δ • ͜ΕΒ͸ Reference Guide Ͱઆ໌͞ΕͯΔ Security ΋ద੾ʹ͢Δ
  10. • Client ͷ Server ొ࿥༻ͷεϨου໊͕ registrationTask1 ͰΑ͘Θ͔ΒΜॴ • Http Traces

    ͸ɺͦͦ͜͜ͷτϥϑΟοΫ͕͋Δͱϩʔυ଴ͪͰݻ·Δ • MBean ΛΧδϡΞϧʹ Web ͰฤूͰ͖Δ/ Log level ΋ฤूͰ͖Δͷ͸ා͍ͷ Ͱɺ actuator ͷ PATH ʹରͯ͠΋ REMOTE ADDR ͰͷΞΫηε੍ޚ΍ Spring Boot Admin ࣗମͷೝূ΋͔ͬ͠Γ࡞Γࠐ·ͳ͍ͱةݥ • Environment/Configuration Properties ΋σϑΥϧτͰ password/token ͳͲ͸Ϛε Ϋ͞ΕΔ͕ɺ௕͘ӡ༻͍ͯ͠Δͱઈର࿙Ε͕ൃੜͯ͠ϦεΫ্͕ΔͷͰɺ্هͱ ಉ͔ͬ͘͡͠ΓΞΫηε੍ޚ͸࣮૷͠ͳ͍ͱͩΊ • Http Traces ͸ default Ͱ request header ͳͲΛશ෦ग़ྗͪ͠Όͬͯةݥ౓ߴ͍ͷ Ͱલड़ͷΦεεϝઃఆ͸࠷௿ݶೖΕͱ͔ͳ͍ͱةͳ͍ ؾʹͳΔͱ͜Ζ
  11. • Client ͷ Server ొ࿥༻ͷεϨου໊͕ registrationTask1 ͰΑ͘Θ͔ΒΜॴ • Http Traces

    ͸ɺͦͦ͜͜ͷτϥϑΟοΫ͕͋Δͱϩʔυ଴ͪͰݻ·Δ • MBean ΛΧδϡΞϧʹ Web ͰฤूͰ͖Δ/ Log level ΋ฤूͰ͖Δͷ͸ා͍ͷ Ͱɺ actuator ͷ PATH ʹରͯ͠΋ REMOTE ADDR ͰͷΞΫηε੍ޚ΍ Spring Boot Admin ࣗମͷೝূ΋͔ͬ͠Γ࡞Γࠐ·ͳ͍ͱةݥ • Environment/Configuration Properties ΋σϑΥϧτͰ password/token ͳͲ͸Ϛε Ϋ͞ΕΔ͕ɺ௕͘ӡ༻͍ͯ͠Δͱઈର࿙Ε͕ൃੜͯ͠ϦεΫ্͕ΔͷͰɺ্هͱ ಉ͔ͬ͘͡͠ΓΞΫηε੍ޚ͸࣮૷͠ͳ͍ͱͩΊ • Http Traces ͸ default Ͱ request header ͳͲΛશ෦ग़ྗͪ͠Όͬͯةݥ౓ߴ͍ͷ Ͱલड़ͷΦεεϝઃఆ͸࠷௿ݶೖΕͱ͔ͳ͍ͱةͳ͍ ؾʹͳΔͱ͜Ζ Spring Boot Admin ͳΒͰ͸ͷ෦෼͕গͳ͔ͬͨɻɻ
  12. • ΞϓϦέʔγϣϯͷϏϧυόʔδϣϯΛ List View ͰݟΕΔΑ͏ʹ • Πϯελϯε ID ΛΘ͔Γ΍͍ͨ͘͢͠ •

    ଟ෼ࣗલͰ InstanceIdGenerator Λ࣮૷ͨ͠ΒͰ͖ͦ͏? • ֤छϦετͰιʔτॱ͕Ṗ͍ͷͰࣗવʹ͍ͨ͠ • υΩϡϝϯτΛ΋͏গ͠Θ͔Γ΍͘͢ɻɻɻ • ΫϥελϦϯά΍௨஌ઃఆपΓ͕ͱ͖ͬͭʹ͔ͬͨ͘ ͜Εཉ͍͠