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.5k
Other Decks in Programming
See All in Programming
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
C++でシェーダを書く
fadis
6
4.1k
Click-free releases & the making of a CLI app
oheyadam
2
120
Better Code Design in PHP
afilina
PRO
0
130
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
480
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
300
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
900
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
150
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.5k
Producing Creativity
orderedlist
PRO
341
39k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Git: the NoSQL Database
bkeepers
PRO
427
64k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Optimizing for Happiness
mojombo
376
70k
Scaling GitHub
holman
458
140k
Bash Introduction
62gerente
608
210k
Visualization
eitanlees
145
15k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
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 :)