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

Spring Cloud Sleuth + Zipkin
 with Elasticsearch #zipkin_jp

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. Spring Cloud Sleuth + Zipkin

    with Elasticsearch
    Shin Tanimoto

    Acroquest Technology Co., LTD

    View full-size slide

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

    View full-size slide

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

    2೥લ

    View full-size slide

  4. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    4
    ϚΠΫϩαʔϏε։ൃΛ͓ͯ͠Γ

    ʮαʔϏεͷґଘؔ܎ʯ͕෼͔Βͳ͍

    ͱ͍͏໰୊͕ݦࡏԽ͍ͯͨ͠ͷͰ

    Կ͔πʔϧΛ࡞Ζ͏ͱߟ͍͑ͯͨ

    View full-size slide

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

    View full-size slide

  6. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    6
    Spring Cloud ͢ΓΎʔ͢

    ʢ೔ຊਓʹ͸ฉ͖औΕͳ͍ӳޠʣ

    View full-size slide

  7. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    7
    ຊ೔ͷςʔϚɿ
    Spring Cloud Sleuthͱ

    zipkinΛ༻͍ͨ

    ʮϚΠΫϩαʔϏεͷՄࢹԽʯ

    View full-size slide

  8. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    8
    αʔϏε͕૿͑Δͱ

    ৽͍͠ࠔΓ͝ͱ͕

    ৭ʑͱग़ͯ͘Δ݅

    View full-size slide

  9. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    9
    #1


    ϚΠΫϩαʔϏε։ൃ
    ͷۤ೰

    View full-size slide

  10. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    1. ϚΠΫϩαʔϏε։ൃͷۤ೰
    JAR Hell͔ΒService Hell΁
    αʔϏεͷ਺͕૿େ͢Δ͜ͱͰ

    αʔϏεಉ࢜ͷґଘؔ܎͕෼͔Βͳ͘ͳΔ
    ͜ͷαʔϏεΛվम͢ΔͱͲ͜ʹӨڹ͢Δʁ
    ͍·ى͖ͨΤϥʔ͸Ͳ͕͜ݪҼͳͷʁ
    ͦ΋ͦ΋࢖ΘΕͯͳ͍αʔϏε͸ͳ͍ͷʁ
    10

    View full-size slide

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

    ͲͷϩάϑΝΠϧΛݟΕ͹͍͍ͷʁ
    11

    View full-size slide

  12. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    1. ϚΠΫϩαʔϏε։ൃͷۤ೰
    12
    ཱ৔ʹΑͬͯۤ೰͸ҟͳΔ͕

    ͍ͣΕʹͤΑαʔϏε͚ͩͰͳ͘

    αʔό΍ϩά͕૿͑ͨ͜ͱͰ

    ݟΔ΂͖΋ͷ͕൥ࡶԽ͢Δ

    View full-size slide

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

    View full-size slide

  14. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    14
    #2


    ՄࢹԽʹ࢖͏πʔϧ܈

    View full-size slide

  15. 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

    View full-size slide

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

    View full-size slide

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

    Λ୳͢

    View full-size slide

  18. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    18
    #3


    αʔϏεґଘੑͷ

    ՄࢹԽ

    View full-size slide

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


    → ओʹ։ൃऀ޲͚ͷՄࢹԽͰ͋Δ
    19

    View full-size slide

  20. 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

    View full-size slide

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

    ϚΠΫϩαʔϏε

    View full-size slide

  22. 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ʹૹΔ
    ஝ੵ
    ՄࢹԽ

    View full-size slide

  23. 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

    View full-size slide

  24. 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);
    }
    }

    View full-size slide

  25. 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)

    View full-size slide

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

    View full-size slide

  27. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    27
    ͜͏͍͏ࣄ͕؆୯ʹͰ͖Δ͔Β

    Spring CloudΛ࢖͏Μͩ

    ͍ͬͯ͏ײ֮ɺ͋Γ·͢

    View full-size slide

  28. 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

    View full-size slide

  29. 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

    View full-size slide

  30. 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

    View full-size slide

  31. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    31
    ʢ࠶ʣ

    ͜͏͍͏ࣄ͕؆୯ʹͰ͖Δ͔Β

    Spring CloudΛ࢖͏Μͩ

    ͍ͬͯ͏ײ֮ɺ͋Γ·͢

    View full-size slide

  32. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    32
    #4


    ElasticsearchʹΑΔ

    ӬଓԽ

    View full-size slide

  33. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    4. ElasticsearchʹΑΔӬଓԽ
    33
    όοΫΤϯυ͸in-memoryҎ֎ʹ

    MySQLɺCassandra

    ElasticsearchͳͲ͕બ΂Δ͚Ͳ

    View full-size slide

  34. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    4. ElasticsearchʹΑΔӬଓԽ
    34
    όοΫΤϯυΛ

    Elasticsearchʹ͢Ε͹

    Kibanaͱ͔ͰՄࢹԽͰ͖Μ͡ΌͶʁ

    View full-size slide

  35. 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

    View full-size slide

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

    View full-size slide

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

    ՄࢹԽͰ͖΁Μ΍Μɾɾɾ

    View full-size slide

  38. 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

    View full-size slide

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

    View full-size slide

  40. 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

    View full-size slide

  41. Copyright © Acroquest Technology Co., Ltd. All rights reserved.
    41
    Enjoy visualizing your Spring Cloud
    Applications!

    View full-size slide