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
820
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
レガシーな Android アプリのリアーキテクチャ戦略
oidy
1
170
PLoP 2024: The evolution of the microservice architecture pattern language
cer
PRO
0
1.6k
ECSのサービス間通信 4つの方法を比較する 〜Canary,Blue/Greenも添えて〜
tkikuc
11
2.3k
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
9
1k
開発効率向上のためのリファクタリングの一歩目の選択肢 ~コード分割~ / JJUG CCC 2024 Fall
ryounasso
0
360
WEBエンジニア向けAI活用入門
sutetotanuki
0
300
OpenTelemetryでRailsのパフォーマンス分析を始めてみよう(KoR2024)
ymtdzzz
4
1.6k
Nuxtベースの「WXT」でChrome拡張を作成する | Vue Fes 2024 ランチセッション
moshi1121
1
520
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
430
Honoの来た道とこれから
yusukebe
19
3k
リリース8年目のサービスの1800個のERBファイルをViewComponentに移行した方法とその結果
katty0324
5
3.6k
Vue SFCのtemplateでTypeScriptの型を活用しよう
tsukkee
3
1.5k
Featured
See All Featured
Being A Developer After 40
akosma
86
590k
Fireside Chat
paigeccino
32
3k
Agile that works and the tools we love
rasmusluckow
327
21k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
GitHub's CSS Performance
jonrohan
1030
460k
Docker and Python
trallard
40
3.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
Bash Introduction
62gerente
608
210k
Become a Pro
speakerdeck
PRO
24
5k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.6k
For a Future-Friendly Web
brad_frost
175
9.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
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 :)