Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Micrometer入門 #javaq / introduce-to-micrometer
Search
Manabu Matsuzaki
October 08, 2019
Programming
1
2.7k
Micrometer入門 #javaq / introduce-to-micrometer
Javaコミュ@福岡 勉強会1910 での発表資料です
https://javaq.connpass.com/event/147444/
Manabu Matsuzaki
October 08, 2019
Tweet
Share
More Decks by Manabu Matsuzaki
See All by Manabu Matsuzaki
Spring BootユーザのためのArmeria入門 #jsug / Introduce to Armeria for Spring users
matsumana
0
2.7k
Canary Release with Argo Rollouts #ふくばねてす / canary-release-with-argo-rollouts
matsumana
1
1.1k
Getting started Central Dogma with Golang #fukuokago #umedago / getting-started-central-dogma-with-golang
matsumana
0
860
ArmeriaとCentral Dogmaから学ぶ、マイクロサービスに必要な機能 #edayfuk / lean-from-armeria-and-central-dogma
matsumana
0
4.1k
SREcon19 Americas 参加レポート #srefukuoka / srecon19-americas-report
matsumana
0
830
SRE入門 & チームで取り組んでいるSRE #srefukuoka / introduce-to-sre
matsumana
0
1.2k
Introduce to Armeria and Central Dogma #GWD_Nulab / introduce-to-armeria-and-central-dogma
matsumana
0
550
Connector/JでMaster/Slave Replication構成のMySQLに接続する #mysql_casual_fukuoka /connector-j-master-slave-replication
matsumana
0
1.4k
ユーザ目線でのPrometheus #mackerel_ug /monitoring-prometheus
matsumana
1
3.5k
Other Decks in Programming
See All in Programming
Haze - Real time background blurring
chrisbanes
1
520
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
7
1.4k
毎日13時間もかかるバッチ処理をたった3日で60%短縮するためにやったこと
sho_ssk_
1
240
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
300
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
8
1.8k
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
100
Security_for_introducing_eBPF
kentatada
0
110
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
790
103 Early Hints
sugi_0000
1
250
php-conference-japan-2024
tasuku43
0
350
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
良いユニットテストを書こう
mototakatsu
8
3k
Featured
See All Featured
The Invisible Side of Design
smashingmag
298
50k
Done Done
chrislema
182
16k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
We Have a Design System, Now What?
morganepeng
51
7.3k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Building Applications with DynamoDB
mza
91
6.1k
BBQ
matthewcrist
85
9.4k
KATA
mclloyd
29
14k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Transcript
Micrometerೖ JavaίϛϡˏԬ ษڧձ1910 2019/10/08 @matsumana
Self Introduction • Nameɿ Manabu Matsuzaki • Work atɿ LINE
Fukuoka Corporation • Roleɿ SRE • Twitterɿ @matsumana
Agenda • Micrometerೖ • MicrometerͷओཁͳMeterͱTag • MicrometerΛ͏ • Micrometerͷ֤छMeterΛͬͯࣗͰϝτϦΫεΛه͢Δ •
Spring BootΞϓϦͰ͏ • Binder • Demo
͜ͷࢿྉҎԼͷόʔδϣϯΛݩʹ࡞͍ͯ͠·͢ • Micrometer: 1.3.0 (LTS) • https://github.com/micrometer-metrics/micrometer/releases • Spring Boot:
2.2.0 RC1 • https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.2- Release-Notes • Armeria: 0.94.0 (Micrometerͷ͍ํͷαϯϓϧͱͯ͠հ͠·͢) • https://github.com/line/armeria/releases
Micrometerͱʁ
https://micrometer.io/
Micrometer͕αϙʔτ͍ͯ͠Δ ϞχλϦϯάγεςϜ • Datadog • Prometheus • Elasticsearch • etc…
MicrometerͷओཁͳMeterͱTag
ओཁͳMeter આ໌ Counter ୯७૿Ճ͢ΔϝτϦΫε ྫʣग़ྗͨ͠logͷճ Gauge ্͕Լ͢ΔϝτϦΫε ྫʣin-flight(ݱࡏॲཧத)ͷϦΫΤετ Timer ϝιουͷॲཧ࣌ؒܭଌͳͲ
LongTaskTimer ͕͔͔࣌ؒΔॲཧͷ࣌ؒܭଌ DistributionSummary Πϕϯτͷαϯϓϧ ྫʣhttpͷrequest/responseαΠζ
TagͰϝτϦΫεʹใΛՃ͢Δ • Tagkey-valueͷϖΞ • 1ͭͷϝτϦΫεʹରͯ͠ෳͷTagΛՃͰ͖Δ • Tag͕࣮ࡍͷϝτϦΫεͰͲ͏ѻΘΕΔ͔ɺ ͕ࣗ͏ϞχλϦϯάγεςϜ࣍ୈ
TagͰϝτϦΫεʹใΛՃ͢Δ • Πϝʔδɿ TagΛαϙʔτ͢ΔϞχλϦϯάγεςϜ TagΛαϙʔτ͠ͳ͍ϞχλϦϯάγεςϜ http_server_requests{uri=“/foo”, status=“200"} 10 http_server_requests_foo_200 10
http_server_requests{uri=“/foo”, status=“500"} 2 http_server_requests_foo_500 20 http_server_requests{uri=“/bar”, status=“200"} 21 http_server_requests_bar_200 21 http_server_requests{uri=“/bar”, status=“500"} 4 http_server_requests_bar_500 4
Tag͕͑Δ Tag͕͑ͳ͍ AppOptics, Atlas, Azure Monitor, Cloudwatch, Datadog, Datadog StatsD,
Dynatrace, Elastic, Humio, Influx, KairosDB, New Relic, Prometheus, SignalFx, Sysdig StatsD, Telegraf StatsD, Wavefront Graphite, Ganglia, JMX, Etsy StatsD ֤ϞχλϦϯάγεςϜͷTagαϙʔτ https://micrometer.io/docs/concepts#_supported_monitoring_systems
ϝτϦΫεͱTagͷ໋໊نଇ • ϝτϦΫεͱLabelͷ໊લେࣄͰ͢ • MicrometerͷυΩϡϝϯτ • Naming meters: https://micrometer.io/docs/concepts#_naming_meters •
PrometheusͷυΩϡϝϯτ • Metric and label naming: https://prometheus.io/docs/practices/naming/
MicrometerΛ͏
Micrometerͷ֤छMeterΛͬͯ ࣗͰϝτϦΫεΛه͢Δ
αϯϓϧϓϩάϥϜ • Micrometerιʔεrepoʹ͋ΔαϯϓϧϓϩάϥϜ • https://github.com/micrometer-metrics/micrometer/tree/v1.3.0/ samples/micrometer-samples-core/src/main/java/io/micrometer/ core/samples • CounterSample.java •
GaugeSample.java • TimerSample.java
αϯϓϧϓϩάϥϜ • Micrometerͷ͍ํArmeriaࢀߟʹͳΓ·͢ • ྫʣϦΫΤετ/ϨεϙϯεͷϝτϦΫε • https://github.com/line/armeria/blob/armeria-0.94.0/core/src/main/java/com/linecorp/ armeria/internal/metric/RequestMetricSupport.java#L241-L247 • https://github.com/line/armeria/blob/armeria-0.94.0/core/src/main/java/com/linecorp/
armeria/common/logging/DefaultRequestLog.java • ϦΫΤετޭɺϦΫΤετΤϥʔ (Counter) • ϦΫΤετॲཧ࣌ؒ (Timer) • ϦΫΤεταΠζɺϨεϙϯεαΠζ (DistributionSummary)
Spring BootΞϓϦͰ͏
ΞϓϦέʔγϣϯઃఆ (Must) • ActuatorΛґଘϥΠϒϥϦʹՃ org.springframework.boot:spring-boot-starter-actuator • ͕ࣗ͏ϞχλϦϯάγεςϜ༻ͷґଘϥΠϒϥϦՃ • Prometheusͷ߹: io.micrometer:micrometer-registry-prometheus
• Datadogͷ߹: io.micrometer:micrometer-registry-datadog
ΞϓϦέʔγϣϯઃఆ (Optional) • Prometheusͷ߹ɺΞϓϦέʔγϣϯଆʹPrometheusαʔό͕ Scrape͢ΔEndpoint͕ඞཁɻ • application.yml(or application.properties)ʹઃఆΛߦ͏ • management.endpoints.web.exposure.includeʹprometheusΛՃ
ྫʣ management.endpoints.web.exposure.include=info, health, prometheus
ΞϓϦέʔγϣϯઃఆʢ͓͢͢Ίʣ • ݸਓతʹɺҎԼઃఆ͢ΔࣄΛ͓͢͢Ί • URIຖͷϨΠςϯγͷϝτϦΫε management.metrics.distribution.percentiles.http.server.requests
ؔ࿈υΩϡϝϯτͱࢀߟϒϩά • Spring Boot Actuator: Production-ready Features https://docs.spring.io/spring-boot/docs/2.2.0.RC1/reference/html/ production-ready-features.html •
Spring BootΞϓϦͷϝτϦΫεΛMicrometerͰऩू͢Δ https://matsumana.info/blog/2018/05/23/collect-spring-boot-app- metrics-with-micrometer/ • ϨΠςϯγʔΛܭࢉ͢Δٕज़ͷ https://engineering.linecorp.com/ja/blog/latency-calculation-techniques/
Binder
Binderͱʁ • ϞχλϦϯάର(JVM/APαʔό/ϥΠϒϥϦͳͲ)ͱMicrometerͱͷͭͳ͗ • ϞχλϦϯάର͕͍ࣗ࣋ͬͯΔϝτϦΫεΛMicrometerܦ༝ͰϞχλϦ ϯάγεςϜʹૹΔࣄ͕Ͱ͖Δ • Micrometerͷඪ४Binder https://github.com/micrometer-metrics/micrometer/tree/v1.3.0/micrometer- core/src/main/java/io/micrometer/core/instrument/binder
• JVMɺTomcatɺJettyɺLogbackɺCaffeineɺetc…
Binderͱʁ • ྫ͑ɺJVMؔ࿈ͷϝτϦΫεҎԼ • https://github.com/micrometer-metrics/micrometer/tree/v1.3.0/ micrometer-core/src/main/java/io/micrometer/core/instrument/binder/jvm • JvmGcMetrics.java • JvmMemoryMetrics.java
• JvmThreadMetrics.java • ClassLoaderMetrics.java
DEMO • αϯϓϧΞϓϦ • https://github.com/matsumana/micrometer-example • DatadogʹϝτϦΫεΛอଘ͢Δ • PrometheusʹϝτϦΫεΛอଘͯ͠GrafanaͰՄࢹԽ͢Δ •
JVMϝτϦΫεͷμογϡϘʔυ • HikariCPϝτϦΫεͷμογϡϘʔυ
·ͱΊ • MicrometerͷओཁͳMeterͱTagʹ͍ͭͯઆ໌͠·ͨ͠ • MeterΛͬͯϝτϦΫεΛه͢Δํ๏ʹ͍ͭͯઆ໌͠·ͨ͠ • Binderʹ͍ͭͯઆ໌͠·ͨ͠ • DatadogɺPrometheusͷσϞΛ͓ݟͤ͠·ͨ͠ •
JVMͱHikariCPͷϝτϦΫεΛGrafanaͰՄࢹԽͯ͠Έ·ͨ͠
Thank you :)