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

Spring Cloud Sleuth + Zipkin
 with Elasticsearc...

Spring Cloud Sleuth + Zipkin
 with Elasticsearch #zipkin_jp

Shin Tanimoto

June 13, 2017
Tweet

More Decks by Shin Tanimoto

Other Decks in Technology

Transcript

  1. Copyright © Acroquest Technology Co., Ltd. All rights reserved. ࣗݾ঺հ

    2 • ୩ຊ ৺ (Shin Tanimoto) - Acroquest Technologyגࣜձࣾ - ࠷ۙ͸Elasticsearchؔ܎ͷ࢓ࣄ - ೔ຊJavaϢʔβʔάϧʔϓ - JavaOne / SpringOneεϐʔΧʔ - Twitter : @cero_t - Facebook : shin.tanimoto
  2. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 3 ࢲͱzipkinͷग़ձ͍͸
 2೥લ
  3. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 4 ϚΠΫϩαʔϏε։ൃΛ͓ͯ͠Γ
 ʮαʔϏεͷґଘؔ܎ʯ͕෼͔Βͳ͍
 ͱ͍͏໰୊͕ݦࡏԽ͍ͯͨ͠ͷͰ
 Կ͔πʔϧΛ࡞Ζ͏ͱߟ͍͑ͯͨ
  4. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 5 ͋ΔΑʂ by Josh Long
  5. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 6 Spring Cloud ͢ΓΎʔ͢
 ʢ೔ຊਓʹ͸ฉ͖औΕͳ͍ӳޠʣ
  6. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 7 ຊ೔ͷςʔϚɿ Spring Cloud Sleuthͱ
 zipkinΛ༻͍ͨ
 ʮϚΠΫϩαʔϏεͷՄࢹԽʯ
  7. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 8 αʔϏε͕૿͑Δͱ
 ৽͍͠ࠔΓ͝ͱ͕
 ৭ʑͱग़ͯ͘Δ݅
  8. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 9 #1
 
 ϚΠΫϩαʔϏε։ൃ ͷۤ೰
  9. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 1. ϚΠΫϩαʔϏε։ൃͷۤ೰ JAR Hell͔ΒService Hell΁ αʔϏεͷ਺͕૿େ͢Δ͜ͱͰ
 αʔϏεಉ࢜ͷґଘؔ܎͕෼͔Βͳ͘ͳΔ ͜ͷαʔϏεΛվम͢ΔͱͲ͜ʹӨڹ͢Δʁ ͍·ى͖ͨΤϥʔ͸Ͳ͕͜ݪҼͳͷʁ ͦ΋ͦ΋࢖ΘΕͯͳ͍αʔϏε͸ͳ͍ͷʁ 10
  10. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 1. ϚΠΫϩαʔϏε։ൃͷۤ೰ ӡ༻ऀͩͬͯࠔΔ ؂ࢹ͢΂͖αʔό΍ϓϩηεͷ਺͕ଟ͍ ͢΂ͯͷαʔόͷσΟεΫ΍ϝϞϦ͸େৎ෉ʁ 1000ݸͷϓϩηε͸͢΂ͯਖ਼ৗʹಈ͍͍ͯΔʁ ϩάϑΝΠϧ͕෼ࢄͯ͠͠·͏ ͍·ى͖ͨΤϥʔΛௐ΂ΔͨΊʹɺ
 ͲͷϩάϑΝΠϧΛݟΕ͹͍͍ͷʁ 11
  11. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 1. ϚΠΫϩαʔϏε։ൃͷۤ೰ 12 ཱ৔ʹΑͬͯۤ೰͸ҟͳΔ͕
 ͍ͣΕʹͤΑαʔϏε͚ͩͰͳ͘
 αʔό΍ϩά͕૿͑ͨ͜ͱͰ
 ݟΔ΂͖΋ͷ͕൥ࡶԽ͢Δ
  12. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 13 ͦ͜ͰՄࢹԽͰ͢Α
  13. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 14 #2
 
 ՄࢹԽʹ࢖͏πʔϧ܈
  14. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 2. ՄࢹԽʹ࢖͏πʔϧ܈ ͨͱ͑͹͜͏͍͏πʔϧ܈ αʔϏεؒͷґଘੑΛՄࢹԽʢࠓ೔࿩͢΍ͭʣ Elasticsearch + Spring Cloud Sleuth + Zipkin
 ϩάϑΝΠϧΛՄࢹԽʢࠓ೔͸࿩͞ͳ͍΍ͭʣ Elasticsearch + Logstash + Kibana + Filebeat
 αʔό΍ϓϩηεͷঢ়ଶΛՄࢹԽʢࠓ೔͸࿩͞ͳ͍΍ͭʣ Elasticsearch + Kibana + Metricbeat 15
  15. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 16 ඦฉ͸Ұݟʹ͔ͣ͠
  16. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 2. ՄࢹԽʹ࢖͏πʔϧ܈ Spring Cloud Sleuth + Zipkin 17 ϘτϧωοΫ
 Λ୳͢
  17. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 18 #3
 
 αʔϏεґଘੑͷ
 ՄࢹԽ
  18. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 3. αʔϏεґଘੑͷՄࢹԽ ԿͷͨΊʹ΍Δͷʁ αʔϏεͷվम࣌ʹɺͦͷӨڹൣғΛ֬ೝ͍ͨ͠ Τϥʔ͕ൃੜͨ͠ࡍʹɺ֬ೝ͢΂͖ൣғΛಛఆ͍ͨ͠ ΋͠ɺ࣮ࡍʹ͸࢖ΘΕ͍ͯͳ͍αʔϏε͕͋Ε͹ఀࢭ ͍ͨ͠
 
 → ओʹ։ൃऀ޲͚ͷՄࢹԽͰ͋Δ 19
  19. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 3. αʔϏεґଘੑͷՄࢹԽ Spring Cloud Sleuth + ZipkinͰαʔϏεґଘੑΛՄࢹԽ Spring Cloud Sleuthͱ͸ʁ Distributed Tracing ෳ਺αʔόΛލ͕ΔϦΫΤετʹڞ௨ͷIDΛৼͬͯ
 ʢHTTP/AMQPϔομͳͲͰ఻೻ͤ͞ͳ͕Βʣ
 ॲཧΛ௥੻Ͱ͖ΔΑ͏ʹ͢Δ࢓૊Έ
 Zipkinͱ͸ʁ Distributed Tracing Visualization ෳ਺αʔόΛލ͕ΔϦΫΤετΛՄࢹԽ͢Δ 20
  20. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 3. αʔϏεґଘੑͷՄࢹԽ Spring Cloud Sleuth + ZipkinͷΠϝʔδ 21 Microservice1 Microservice2 طʹ࡞ͬͯ͋Δ
 ϚΠΫϩαʔϏε
  21. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 3. αʔϏεґଘੑͷՄࢹԽ Spring Cloud Sleuth + ZipkinͷΠϝʔδ 22 Microservice1 Microservice2 Zipkin Server HTTP Zipkin UI Server SleuthΛ࢖ͬͯ
 ݺͼग़͠৘ใΛ
 zipkinʹૹΔ ஝ੵ ՄࢹԽ
  22. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 3. αʔϏεґଘੑͷՄࢹԽ Spring Cloud Sleuth + Zipkinͷద༻ Spring Cloud Sleuth ϚΠΫϩαʔϏεͷpom.xmlͷdependenciesʹ
 ʮspring-cloud-starter-zipkinʯΛ௥Ճ ίʔυͷมߋ͸Ұ੾ͳ͠ Zipkin ৽نϓϩδΣΫτΛ࡞ͬͯpom.xmlʹ
 ʮzipkin-serverʯͱʮzipkin-autoconfigure-uiʯΛ௥Ճ MainΫϥεΛҰͭ࡞Δ 23
  23. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 3. αʔϏεґଘੑͷՄࢹԽ Zipkinαʔόͷ։ൃ 24 @SpringBootApplication @EnableZipkinServer public class ZipkinApplication { public static void main(String[] args) { SpringApplication.run(ZipkinApplication.class, args); } }
  24. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 3. αʔϏεґଘੑͷՄࢹԽ Spring Cloud Sleuth + ZipkinͷΠϝʔδ 25 Microservice1 Microservice2 Zipkin Server HTTP Zipkin UI Server Zipkin Client 
 (spring-cloud-starter-zipkin) Zipkin UI (zipkin-autoconfigure-ui)
 Zipkin Server (zipkin-server)
  25. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. ͦΖͦΖσϞ 26 Demo
  26. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 27 ͜͏͍͏ࣄ͕؆୯ʹͰ͖Δ͔Β
 Spring CloudΛ࢖͏Μͩ
 ͍ͬͯ͏ײ֮ɺ͋Γ·͢
  27. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 3. αʔϏεґଘੑͷՄࢹԽ ΋͏গ͠৴པੑͷߴ͍ऩू 28 Microservice1 Microservice2 Zipkin Server Zipkin UI
 Server Kafka
  28. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 3. αʔϏεґଘੑͷՄࢹԽ ΋͏গ͠৴པੑͷߴ͍ऩू 29 Microservice1 Microservice2 Zipkin Server Zipkin UI
 Server Kafka spring-cloud-sleuth-stream
 spring-cloud-stream-binder-kafka zipkin-autoconfigure-ui
 spring-cloud-sleuth-zipkin-stream
 spring-cloud-stream-binder-kafka
  29. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 3. αʔϏεґଘੑͷՄࢹԽ Spring Cloud Sleuth + ZipkinͷΠϝʔδ 30 Name artifactId Log HTTP Kafka Sleuth spring-cloud-starter-sleuth Service Sleuth Stream spring-cloud-sleuth-stream Service Zipkin Client spring-cloud-starter-zipkin Service Zipkin Stream spring-cloud-sleuth-zipkin-stream Zipkin Zipkin UI spring-boot-starter
 zipkin-autoconfigure-ui Zipkin Zipkin Zipkin Server spring-boot-starter
 zipkin-server Zipkin Stream Kafka spring-cloud-stream-binder-kafka Both
  30. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 31 ʢ࠶ʣ
 ͜͏͍͏ࣄ͕؆୯ʹͰ͖Δ͔Β
 Spring CloudΛ࢖͏Μͩ
 ͍ͬͯ͏ײ֮ɺ͋Γ·͢
  31. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 32 #4
 
 ElasticsearchʹΑΔ
 ӬଓԽ
  32. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 4. ElasticsearchʹΑΔӬଓԽ 33 όοΫΤϯυ͸in-memoryҎ֎ʹ
 MySQLɺCassandra
 ElasticsearchͳͲ͕બ΂Δ͚Ͳ
  33. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 4. ElasticsearchʹΑΔӬଓԽ 34 όοΫΤϯυΛ
 Elasticsearchʹ͢Ε͹
 Kibanaͱ͔ͰՄࢹԽͰ͖Μ͡ΌͶʁ
  34. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 4. ElasticsearchʹΑΔӬଓԽ ElasticsearchʹΑΔZipkinͷӬଓԽ ґଘϥΠϒϥϦͷ௥Ճ zipkinϓϩδΣΫτͷpom.xmlͷdependenciesʹ
 ʮzipkin-autoconfigure-storage-elasticsearch-httpʯΛ௥Ճ -elasticsearch-aws͸Amazon ESઐ༻ʢͨͿΜʣ zipkinϓϩδΣΫτͷapplication.ymlʹ
 ʮzipkin.storage.type: elasticsearchʯΛ௥Ճ 35
  35. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. ΋͏Ұ౓σϞ 36 Demo
  36. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 4. ElasticsearchʹΑΔӬଓԽ 37 ·ͩ͋Μ·ΓKibanaͰ
 ՄࢹԽͰ͖΁Μ΍Μɾɾɾ
  37. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 4. ElasticsearchʹΑΔӬଓԽ 38 ࠓޙʹظ଴ɾɾɾʁ Zipkin v2 span model #939 https://github.com/openzipkin/zipkin/issues/939
  38. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. 39 ·ͱΊ
  39. Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright

    © Acroquest Technology Co., Ltd. All rights reserved. ·ͱΊ Spring BootͰ։ൃ͍ͯ͠Δօ͞Μ͸
 Spring Cloud SleuthͱZipkinʹΑΔ
 αʔϏεґଘੑͷՄࢹԽ͸͙͢Ͱ͖ΔΑ
 ElasticsearchʹσʔλΛอଘ͢Δ͜ͱ΋Ͱ͖Δ͚Ͳ
 ՄࢹԽ͢Δʹ͸ͪΐͬͱ·ͩਏ͍͔ͳ
 ͪͳΈʹো֐΍γεςϜఀࢭ͕ى͖Δ͜ͱେલఏͱͯ͠ɺ
 KafkaΛ༻͍ͨ҆ఆԽΛݕ౼͢Ε͹ɺؾ͍ͮͨΒSpring Cloud Stream΍
 όοΫϓϨογϟʔͷϝϦοτ͕෼͔ΔΑ͏ʹͳΔΑʂ
 ʢݸਓͷײ૝Ͱ͢ʣ 40
  40. Copyright © Acroquest Technology Co., Ltd. All rights reserved. 41

    Enjoy visualizing your Spring Cloud Applications!