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.8k
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
870
ArmeriaとCentral Dogmaから学ぶ、マイクロサービスに必要な機能 #edayfuk / lean-from-armeria-and-central-dogma
matsumana
0
4.2k
SREcon19 Americas 参加レポート #srefukuoka / srecon19-americas-report
matsumana
0
840
SRE入門 & チームで取り組んでいるSRE #srefukuoka / introduce-to-sre
matsumana
0
1.3k
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
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
130
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
750
ChatGPT とつくる PHP で OS 実装
memory1994
PRO
3
190
AWS Lambda functions with C# 用の Dev Container Template を作ってみた件
mappie_kochi
0
200
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
15
2.6k
2025.01.17_Sansan × DMM.swift
riofujimon
2
610
PicoRubyと暮らす、シェアハウスハック
ryosk7
0
240
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
0
130
watsonx.ai Dojo #6 継続的なAIアプリ開発と展開
oniak3ibm
PRO
0
190
非ブラウザランタイムとWeb標準 / Non-Browser Runtimes and Web Standards
petamoriken
0
440
SRE、開発、QAが協業して挑んだリリースプロセス改革@SRE Kaigi 2025
nealle
1
1.5k
AWSのLambdaで PHPを動かす選択肢
rinchoku
2
390
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
360
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
250
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
970
Rails Girls Zürich Keynote
gr2m
94
13k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Statistics for Hackers
jakevdp
797
220k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
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 :)