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.6k
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.4k
Other Decks in Programming
See All in Programming
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
CSC509 Lecture 09
javiergs
PRO
0
140
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
110
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.1k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
100
Contemporary Test Cases
maaretp
0
130
Amazon Qを使ってIaCを触ろう!
maruto
0
400
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
52
13k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Typedesign – Prime Four
hannesfritz
40
2.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
4 Signs Your Business is Dying
shpigford
180
21k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Teambox: Starting and Learning
jrom
133
8.8k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
A better future with KSS
kneath
238
17k
A designer walks into a library…
pauljervisheath
203
24k
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 :)