Movatterモバイル変換


[0]ホーム

URL:


Toshiaki Maki, profile picture
Uploaded byToshiaki Maki
PDF, PPTX23,067 views

Spring Boot Actuator 2.0 & Micrometer

Spring Boot Actuator 2.0 has been refactored and now supports Micrometer for instrumentation and metrics collection. Micrometer allows instrumentation without vendor lock-in and supports many monitoring systems including Prometheus, Datadog, and Cloud Foundry Metrics. New features in Spring Boot Actuator 2.0 include support for Spring WebFlux, more secure configuration of endpoints, and histograms and percentiles for more detailed metrics. Micrometer provides a common API for instruments like timers, counters, and gauges and supports adding custom meters.

Embed presentation

Download as PDF, PPTX
1Spring Boot Actuator 2.0 &Micrometer2018-03-27Toshiaki Maki (@making / tmaki@pivotal.io)
Who am I ?2Toshiaki Maki (@making) https://blog.ik.amSr. Solutions Architect @Pivotal JapanSpring / Cloud Foundry / Concourse / Kubernetes" Spring Boot 2": https://note.ik.am (not free!)
What' new in Spring Boot 2X• Infrastructure Update (Spring 5, Tomcat 8.5, Jetty9.4, Hibernete 5.3, HikariCP as a default CP)• Starters for reactive projects• Reactive web test support• new OAuth 2 support• explicit Spring Security configurations• Actuator refactoring / Micrometer support• Kotlin support
Agenda3• Spring Boot Actuator 2• Micrometer• Micrometer• Histograms and percentiles• Micrometer API
Spring Boot Actuator 2
Spring Boot Actuator5Additional features to help you monitor and manageyour application in production.<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
Supported Endpoints6• auditevents• beans• conditions• configprops• env• flyway• health• httptracehttps://demo-micrometer.cfapps.io/actuatorhttps://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html• info• loggers• liquibase• metrics• mappings• scheduledtasks• sessions• shutdown• threaddump• heapdump• jolokia• logfile• prometheus/actuator/*•renamed•added
Technology Support7Spring Boot Actuator 1.x Spring Boot Actuator 2.x•Spring MVC •Spring MVC•Spring WebFlux•Jersey
How to enable endpoints8Default exposed endpoints are /info and /health.management.endpoints.web.exposure.include=*management.endpoints.web.exposure.include=info,health,envAll endpoints are not secured by default.
Secure endpoints (Spring MVC)9http.authorizeRequests().mvcMatchers("/actuator/health", "/actuator/info").permitAll().mvcMatchers("/actuator/**")
.hasRole("ACTUATOR").anyRequest().permitAll().and().httpBasic().and()...
Secure endpoints (Spring MVC)9http.authorizeRequests().mvcMatchers("/actuator/health", "/actuator/info").permitAll().mvcMatchers("/actuator/**")
.hasRole("ACTUATOR").anyRequest().permitAll().and().httpBasic().and()... spring.security.user.name=hogespring.security.user.password=foospring.security.user.roles=ACTUATOR
Secure endpoints (Spring MVC)10http.authorizeRequests().requestMatchers(EndpointRequest.to("health", "info")).permitAll().requestMatchers(EndpointRequest.toAnyEndpoint())
.hasRole("ACTUATOR").anyRequest().permitAll().and().httpBasic().and()...
Secure endpoints (Spring WebFlux)11http.authorizeExchange().matchers(EndpointRequest.to("health", "info")).permitAll().matchers(EndpointRequest.toAnyEndpoint())
.hasRole("ACTUATOR").anyExchange().permitAll().and().httpBasic().and()...
Health Check12management.endpoint.health.show-details=when_authorizedwhen authorized
Cloud Foundry Support13 https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/production-ready-cloudfoundry.html
Micrometer
Micrometer15Move to MicrometerThink SLF4J, but for MetricsInstrument without vendor lock-in:• Prometheus• Netflix Atlas• Datadog• InfluxDB• ...Multi-dementional metricshttps://micrometer.io/
Supported monitoring systems16Server polls Client pushesPrometheusAtlas, Datadog, Datadog StatsD,Influx, SignalFx, Telegraf StatsD,Wavefront, New RelicDimensionalGraphite, Ganglia, JMX, Etsy StatsD,PCF Metrics 1.4Hierarchicalpushpoll
Prometheus17<dependency><groupId>io.micrometer</groupId><artifactId>micrometer-registry-prometheus</artifactId></dependency>
/actuator/prometheus18system_cpu_count 4.0system_load_average_1m 1.64jvm_memory_max_bytes{area="heap",id="PS Eden Space",}1.05906176E8jvm_memory_max_bytes{area="heap",id="PS Survivor Space",}2.1495808E7jvm_memory_max_bytes{area="heap",id="PS Old Gen",} 3.00941312E8http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/hello",} 4469.0http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="/hello",} 297.942920787http_server_requests_seconds_max{exception="None",method="GET",status="200",uri="/hello",} 0.401581731https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/production-ready-metrics.html#production-ready-metrics-meter
Prometheus19
Grafana20
On Cloud Foundry21@Bean@Profile("cloud")public MeterRegistryCustomizer meterRegistryCustomizer(@Value("${vcap.application.name:}") String name,@Value("${vcap.application.instance_id:}") String id) {return registry -> registry.config().commonTags("cf_app_name", name,"cf_app_instance_id", id);}
On Cloud Foundry22system_cpu_count{cf_app_instance_id="31388366-...",cf_app_name="demo-micrometer",}} 4.0system_load_average_1m{cf_app_instance_id="31388366-...",cf_app_name="demo-micrometer",} 1.64jvm_memory_max_bytes{cf_app_instance_id="31388366-...",cf_app_name="demo-micrometer",area="heap",id="PS Eden Space",}1.05906176E8jvm_memory_max_bytes{cf_app_instance_id="31388366-...",cf_app_name="demo-micrometer",area="heap",id="PS Survivor Space",}2.1495808E7jvm_memory_max_bytes{cf_app_instance_id="31388366-...",cf_app_name="demo-micrometer",area="heap",id="PS Old Gen",} 3.00941312E8
Datadog23<dependency><groupId>io.micrometer</groupId><artifactId>micrometer-registry-datadog</artifactId></dependency>management.metrics.export.datadog.api-key=YOUR-API-KEY
Datadog24
PCF Metrics25Bind Metrics Forwarder Servicehttps://github.com/cloudfoundry/java-buildpack-metric-writer Use Metric Writer 2.4.0+ which comes with JBP 4.10+
Histograms and percentiles
Histogram27management.metrics.distribution.percentiles-histogram.http.server.requests=true
Histogram in Prometheus28http_server_requests_seconds_bucket{...,uri="/hello",le="0.061516456",} 15646.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.067108864",} 15657.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.089478485",} 15679.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.111848106",} 15679.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.134217727",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.156587348",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.178956969",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.20132659",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.223696211",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.246065832",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.268435456",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.357913941",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.447392426",} 16475.0The number of requests that took less than 0.447392426 sec.
Query percentiles in Prometheus29histogram_quantile(0.9,sum(rate(http_server_requests_seconds_bucket{status="200"}[5m])) by (app, uri, le))https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile()
SLA (Service Level Agreement)30management.metrics.distribution.sla.http.server.requests=100ms, 200ms, 400ms
SLA in Prometheus31http_server_requests_seconds_bucket{...,uri="/hello",le="0.061516456",} 15646.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.067108864",} 15657.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.089478485",} 15679.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.1",} 15679.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.111848106",} 15679.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.134217727",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.156587348",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.178956969",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.2",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.20132659",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.223696211",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.246065832",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.268435456",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.357913941",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.4",} 15687.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.447392426",} 16475.0
Monitor user experience by Apdex32Apdex = (Satisfied requests + Tolerating requests / 2)/ Total number of requestsSatisfied: The response time is less than or equal to T.Tolerating: The response time is greater than T and less than or equal to 4T.Frustrated: The response time is greater than 4T.https://docs.newrelic.com/docs/apm/new-relic-apm/apdex/apdex-measuring-user-satisfaction
For example, T = 1.2 [sec]33Level Multiplier Time (T Example = 1.2)Satisfied T or less <= 1.2 secondsTolerating >T, <= 4T Between 1.2 and 4.8secondsFrustrated > 4T Greater than 4.8secondshttps://docs.newrelic.com/docs/apm/new-relic-apm/apdex/apdex-measuring-user-satisfaction
34• During a 2minute period a server handles 200 requests• T = 1.2 [sec]• 170 of the requests were handled within 1.2 sec[Satisfied]• 20 of the requests were handled between 1.2 sec and4.8 sec [Tolerating]• The remaining 10 took longer than 4.8 sec. [Frustrated]• Appdex = (170 + (20 / 2)) / 200 = 0.9For example, T = 1.2 [sec]
Query Appdex (T=100ms) in Prometheus35( sum(rate(http_server_requests_seconds_bucket{le="0.1",status="200"}[5m])) by (app, uri) +sum(rate(http_server_requests_seconds_bucket{le="0.4",status="200"}[5m])) by (app, uri) )https://prometheus.io/docs/practices/histograms/#apdex-score
Monitor Appdex in Grafana36
Client-side Percentile37management.metrics.distribution.percentiles.http.server.requests=0.5, 0.9, 0.95, 0.99, 0.999http_server_requests_seconds{...,uri="/hello",quantile="0.5",} 0.050855935http_server_requests_seconds{...,uri="/hello",quantile="0.9",} 0.051380223http_server_requests_seconds{...,uri="/hello",quantile="0.95",} 0.40265318http_server_requests_seconds{...,uri="/hello",quantile="0.99",} 0.40265318http_server_requests_seconds{...,uri="/hello",quantile="0.999",} 0.40265318
Percentiles for the specific uri in Prometheus38max(http_server_requests_seconds{uri="/hello",status="200", exception="None"}) by (quantile)
Micrometer API
Meter (Timer, Counter, Gauge, ...)40@Componentpublic class FooService {final Counter counter;public FooService(MeterRegistry registry) {this.counter = Counter.builder("received.messages").register(registry);}public void handleMessage() {this.counter.increment();}}Timer, Counter, Gauge, DistributionSummary, LongTaskTimer, FunctionCounter, FunctionTimer, and TimeGauge
Meter (Timer, Counter, Gauge, ...)41@Componentpublic class FooService {final Timer timer;public FooService(MeterRegistry registry) {this.timer = Timer.builder("foo").register(registry);}public String foo() {return this.timer.record(() -> {// ...});}}Timer, Counter, Gauge, DistributionSummary, LongTaskTimer, FunctionCounter, FunctionTimer, and TimeGauge
@Timed42@Componentpublic class FooService {@Timed("foo")public String foo() {// ...}}@Beanpublic TimedAspect timedAspect(MeterRegistry registry) {return new TimedAspect(meterRegistry);} // Not auto-configured in Spring Boot 2.0https://github.com/micrometer-metrics/micrometer/issues/361
MeterFilter43@Beanpublic MeterFilter meterFilter() {return MeterFilter.deny(id -> {String uri = id.getTag("uri");return id != null && uri.startsWith("/actuator");});}Exclude metrics against Actuator endpoints
Add MeterBinders44@Beanpublic HystrixMetricsBinder hystrixMetricsBinder() {return new HystrixMetricsBinder();}@Beanpublic HibernateMetrics hibernateMetrics() {return new HibernateMetrics(...);}Check io.micrometer.core.instrument.binder packageSome binders are auto-configured https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/production-ready-metrics.html#production-ready-metrics-meter
Enjoy Actuator & Micrometer!45Thank you for your attention!• https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/production-ready.html• https://micrometer.io/docs• https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/production-ready-metrics.html• https://blog.ik.am/entries/448• https://github.com/making/demo-micrometer

Recommended

PDF
Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1
PDF
vSphere 7 へのアップグレードについて
PDF
Keycloak拡張入門
PDF
わかる!metadata.managedFields / Kubernetes Meetup Tokyo 48
PDF
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
PDF
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
PDF
Ingress on Azure Kubernetes Service
PPTX
ぼくらのアカウント戦略〜マルチアカウントでのガバナンスと権限管理の全て〜
PDF
Kong, Keyrock, Keycloak, i4Trust - Options to Secure FIWARE in Production
 
PDF
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
PPTX
KeycloakでAPI認可に入門する
PDF
Apache Kafkaって本当に大丈夫?~故障検証のオーバービューと興味深い挙動の紹介~
PPTX
kubernetes初心者がKnative Lambda Runtime触ってみた(Kubernetes Novice Tokyo #13 発表資料)
PPTX
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
PDF
MySQL 5.7にやられないためにおぼえておいてほしいこと
PDF
3分でわかるAzureでのService Principal
PDF
Google Cloud のネットワークとロードバランサ
PPTX
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ
PPTX
Keycloakのステップアップ認証について
PDF
多要素認証による Amazon WorkSpaces の利用
PDF
単なるキャッシュじゃないよ!?infinispanの紹介
PDF
認証の課題とID連携の実装 〜ハンズオン〜
PPTX
急速に進化を続けるCNIプラグイン Antrea
PDF
KeycloakのDevice Flow、CIBAについて
PPTX
[社内勉強会]ELBとALBと数万スパイク負荷テスト
PDF
PostgreSQLをKubernetes上で活用するためのOperator紹介!(Cloud Native Database Meetup #3 発表資料)
PDF
PostgreSQLコミュニティに飛び込もう
PPTX
分散トレーシングAWS:X-Rayとの上手い付き合い方
PDF
Monitoring your Spring Boot and Micronaut microservices with Micrometer
PDF
Controlling your race with Micrometer, Spring Boot and Cloud Foundry

More Related Content

PDF
Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1
PDF
vSphere 7 へのアップグレードについて
PDF
Keycloak拡張入門
PDF
わかる!metadata.managedFields / Kubernetes Meetup Tokyo 48
PDF
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
PDF
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
PDF
Ingress on Azure Kubernetes Service
PPTX
ぼくらのアカウント戦略〜マルチアカウントでのガバナンスと権限管理の全て〜
Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1
vSphere 7 へのアップグレードについて
Keycloak拡張入門
わかる!metadata.managedFields / Kubernetes Meetup Tokyo 48
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
Ingress on Azure Kubernetes Service
ぼくらのアカウント戦略〜マルチアカウントでのガバナンスと権限管理の全て〜

What's hot

PDF
Kong, Keyrock, Keycloak, i4Trust - Options to Secure FIWARE in Production
 
PDF
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
PPTX
KeycloakでAPI認可に入門する
PDF
Apache Kafkaって本当に大丈夫?~故障検証のオーバービューと興味深い挙動の紹介~
PPTX
kubernetes初心者がKnative Lambda Runtime触ってみた(Kubernetes Novice Tokyo #13 発表資料)
PPTX
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
PDF
MySQL 5.7にやられないためにおぼえておいてほしいこと
PDF
3分でわかるAzureでのService Principal
PDF
Google Cloud のネットワークとロードバランサ
PPTX
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ
PPTX
Keycloakのステップアップ認証について
PDF
多要素認証による Amazon WorkSpaces の利用
PDF
単なるキャッシュじゃないよ!?infinispanの紹介
PDF
認証の課題とID連携の実装 〜ハンズオン〜
PPTX
急速に進化を続けるCNIプラグイン Antrea
PDF
KeycloakのDevice Flow、CIBAについて
PPTX
[社内勉強会]ELBとALBと数万スパイク負荷テスト
PDF
PostgreSQLをKubernetes上で活用するためのOperator紹介!(Cloud Native Database Meetup #3 発表資料)
PDF
PostgreSQLコミュニティに飛び込もう
PPTX
分散トレーシングAWS:X-Rayとの上手い付き合い方
Kong, Keyrock, Keycloak, i4Trust - Options to Secure FIWARE in Production
 
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
KeycloakでAPI認可に入門する
Apache Kafkaって本当に大丈夫?~故障検証のオーバービューと興味深い挙動の紹介~
kubernetes初心者がKnative Lambda Runtime触ってみた(Kubernetes Novice Tokyo #13 発表資料)
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
MySQL 5.7にやられないためにおぼえておいてほしいこと
3分でわかるAzureでのService Principal
Google Cloud のネットワークとロードバランサ
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ
Keycloakのステップアップ認証について
多要素認証による Amazon WorkSpaces の利用
単なるキャッシュじゃないよ!?infinispanの紹介
認証の課題とID連携の実装 〜ハンズオン〜
急速に進化を続けるCNIプラグイン Antrea
KeycloakのDevice Flow、CIBAについて
[社内勉強会]ELBとALBと数万スパイク負荷テスト
PostgreSQLをKubernetes上で活用するためのOperator紹介!(Cloud Native Database Meetup #3 発表資料)
PostgreSQLコミュニティに飛び込もう
分散トレーシングAWS:X-Rayとの上手い付き合い方

Similar to Spring Boot Actuator 2.0 & Micrometer

PDF
Monitoring your Spring Boot and Micronaut microservices with Micrometer
PDF
Controlling your race with Micrometer, Spring Boot and Cloud Foundry
PDF
JavaLand - Micrometer and SpringBoot
PDF
Controlling your race with Micrometer and Spring Boot / Micronaut (Brown Bag)
PDF
Controlling your race with Micrometer and Spring Boot (live coding!)
PDF
Spring and Pivotal Application Service - SpringOne Tour - Boston
PPTX
Spring Boot & Spring Cloud Apps on Pivotal Application Service - Daniel Lavoie
PDF
Spring and Pivotal Application Service - SpringOne Tour Dallas
PDF
Code Motion Italy
PDF
Controlling your race with Micrometer, Spring Boot and Cloud Foundry @Geekle
PDF
Spring Boot & Spring Cloud on Pivotal Application Service
PPTX
SpringOne Tour Denver - Spring Boot & Spring Cloud on Pivotal Application Ser...
PPTX
Microservices with kubernetes @190316
PDF
Improving monitoring systems Interoperability with OpenMetrics
PPTX
Spring Cloud Services with Pivotal Cloud Foundry- Gokhan Goksu
PDF
SpringBoot and Spring Cloud Service for MSA
PDF
Introduction to MicroProfile Metrics
PDF
Introduction to MicroProfile Metrics
PPTX
Spring Boot & Spring Cloud on Pivotal Application Service - Alexandre Roman
PPTX
Spring on PAS - Fabio Marinelli
Monitoring your Spring Boot and Micronaut microservices with Micrometer
Controlling your race with Micrometer, Spring Boot and Cloud Foundry
JavaLand - Micrometer and SpringBoot
Controlling your race with Micrometer and Spring Boot / Micronaut (Brown Bag)
Controlling your race with Micrometer and Spring Boot (live coding!)
Spring and Pivotal Application Service - SpringOne Tour - Boston
Spring Boot & Spring Cloud Apps on Pivotal Application Service - Daniel Lavoie
Spring and Pivotal Application Service - SpringOne Tour Dallas
Code Motion Italy
Controlling your race with Micrometer, Spring Boot and Cloud Foundry @Geekle
Spring Boot & Spring Cloud on Pivotal Application Service
SpringOne Tour Denver - Spring Boot & Spring Cloud on Pivotal Application Ser...
Microservices with kubernetes @190316
Improving monitoring systems Interoperability with OpenMetrics
Spring Cloud Services with Pivotal Cloud Foundry- Gokhan Goksu
SpringBoot and Spring Cloud Service for MSA
Introduction to MicroProfile Metrics
Introduction to MicroProfile Metrics
Spring Boot & Spring Cloud on Pivotal Application Service - Alexandre Roman
Spring on PAS - Fabio Marinelli

More from Toshiaki Maki

PDF
From Spring Boot 2.2 to Spring Boot 2.3 #jsug
PDF
Concourse x Spinnaker #concourse_tokyo
PDF
Serverless with Spring Cloud Function, Knative and riff #SpringOneTour #s1t
PDF
決済システムの内製化への旅 - SpringとPCFで作るクラウドネイティブなシステム開発 #jsug #sf_h1
PDF
Open Service Broker APIとKubernetes Service Catalog #k8sjp
PDF
Spring Cloud Function & Project riff #jsug
PDF
Introduction to Spring WebFlux #jsug #sf_a1
PDF
BOSH / CF Deployment in modern ways #cf_tokyo
PDF
Why PCF is the best platform for Spring Boot
PDF
Zipkin Components #zipkin_jp
PPTX
マイクロサービスに必要な技術要素はすべてSpring Cloudにある #DO07
PDF
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
PDF
実例で学ぶ、明日から使えるSpring Boot Tips #jsug
PDF
Spring ❤️ Kotlin #jjug
PDF
Event Driven Microservices with Spring Cloud Stream #jjug_ccc #ccc_ab3
PDF
Managing your Docker image continuously with Concourse CI
PDF
Data Microservices with Spring Cloud Stream, Task, and Data Flow #jsug #spri...
PDF
Short Lived Tasks in Cloud Foundry #cfdtokyo
PDF
今すぐ始めるCloud Foundry #hackt #hackt_k
PDF
Team Support in Concourse CI 2.0 #concourse_tokyo
From Spring Boot 2.2 to Spring Boot 2.3 #jsug
Concourse x Spinnaker #concourse_tokyo
Serverless with Spring Cloud Function, Knative and riff #SpringOneTour #s1t
決済システムの内製化への旅 - SpringとPCFで作るクラウドネイティブなシステム開発 #jsug #sf_h1
Open Service Broker APIとKubernetes Service Catalog #k8sjp
Spring Cloud Function & Project riff #jsug
Introduction to Spring WebFlux #jsug #sf_a1
BOSH / CF Deployment in modern ways #cf_tokyo
Why PCF is the best platform for Spring Boot
Zipkin Components #zipkin_jp
マイクロサービスに必要な技術要素はすべてSpring Cloudにある #DO07
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
実例で学ぶ、明日から使えるSpring Boot Tips #jsug
Spring ❤️ Kotlin #jjug
Event Driven Microservices with Spring Cloud Stream #jjug_ccc #ccc_ab3
Managing your Docker image continuously with Concourse CI
Data Microservices with Spring Cloud Stream, Task, and Data Flow #jsug #spri...
Short Lived Tasks in Cloud Foundry #cfdtokyo
今すぐ始めるCloud Foundry #hackt #hackt_k
Team Support in Concourse CI 2.0 #concourse_tokyo

Recently uploaded

PPTX
Protecting Data in an AI Driven World - Cybersecurity in 2026
PDF
Safeguarding AI-Based Financial Infrastructure
PPTX
AI in Cybersecurity: Digital Defense by Yasir Naveed Riaz
PDF
Unlocking the Power of Salesforce Architecture: Frameworks for Effective Solu...
PDF
Making Sense of Raster: From Bit Depth to Better Workflows
PDF
Is It Possible to Have Wi-Fi Without an Internet Provider
PPTX
Chapter 3 Introduction to number system.pptx
PDF
API-First Architecture in Financial Systems
PDF
ElyriaSoftware — Powering the Future with Blockchain Innovation
PDF
Day 1 - Cloud Security Strategy and Planning ~ 2nd Sight Lab ~ Cloud Security...
PDF
Unser Jahresrückblick – MarvelClient in 2025
PDF
The major tech developments for 2026 by Pluralsight, a research and training ...
PPTX
wob-report.pptxwob-report.pptxwob-report.pptx
DOCX
Introduction to the World of Computers (Hardware & Software)
PDF
Zero Trust & Defense-in-Depth: The Future of Critical Infrastructure Security
PPTX
Cybercrime in the Digital Age: Risks, Impact & Protection
PDF
Six Shifts For 2026 (And The Next Six Years)
PDF
Usage Control for Process Discovery through a Trusted Execution Environment
PPTX
Ethics in AI - Artificial Intelligence Fundamentals.pptx
PDF
December Patch Tuesday
 
Protecting Data in an AI Driven World - Cybersecurity in 2026
Safeguarding AI-Based Financial Infrastructure
AI in Cybersecurity: Digital Defense by Yasir Naveed Riaz
Unlocking the Power of Salesforce Architecture: Frameworks for Effective Solu...
Making Sense of Raster: From Bit Depth to Better Workflows
Is It Possible to Have Wi-Fi Without an Internet Provider
Chapter 3 Introduction to number system.pptx
API-First Architecture in Financial Systems
ElyriaSoftware — Powering the Future with Blockchain Innovation
Day 1 - Cloud Security Strategy and Planning ~ 2nd Sight Lab ~ Cloud Security...
Unser Jahresrückblick – MarvelClient in 2025
The major tech developments for 2026 by Pluralsight, a research and training ...
wob-report.pptxwob-report.pptxwob-report.pptx
Introduction to the World of Computers (Hardware & Software)
Zero Trust & Defense-in-Depth: The Future of Critical Infrastructure Security
Cybercrime in the Digital Age: Risks, Impact & Protection
Six Shifts For 2026 (And The Next Six Years)
Usage Control for Process Discovery through a Trusted Execution Environment
Ethics in AI - Artificial Intelligence Fundamentals.pptx
December Patch Tuesday
 

Spring Boot Actuator 2.0 & Micrometer

  • 1.
    1Spring Boot Actuator2.0 &Micrometer2018-03-27Toshiaki Maki (@making / tmaki@pivotal.io)
  • 2.
    Who am I?2Toshiaki Maki (@making) https://blog.ik.amSr. Solutions Architect @Pivotal JapanSpring / Cloud Foundry / Concourse / Kubernetes" Spring Boot 2": https://note.ik.am (not free!)
  • 3.
    What' new inSpring Boot 2X• Infrastructure Update (Spring 5, Tomcat 8.5, Jetty9.4, Hibernete 5.3, HikariCP as a default CP)• Starters for reactive projects• Reactive web test support• new OAuth 2 support• explicit Spring Security configurations• Actuator refactoring / Micrometer support• Kotlin support
  • 4.
    Agenda3• Spring BootActuator 2• Micrometer• Micrometer• Histograms and percentiles• Micrometer API
  • 5.
  • 6.
    Spring Boot Actuator5Additionalfeatures to help you monitor and manageyour application in production.<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
  • 7.
    Supported Endpoints6• auditevents•beans• conditions• configprops• env• flyway• health• httptracehttps://demo-micrometer.cfapps.io/actuatorhttps://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html• info• loggers• liquibase• metrics• mappings• scheduledtasks• sessions• shutdown• threaddump• heapdump• jolokia• logfile• prometheus/actuator/*•renamed•added
  • 8.
    Technology Support7Spring BootActuator 1.x Spring Boot Actuator 2.x•Spring MVC •Spring MVC•Spring WebFlux•Jersey
  • 9.
    How to enableendpoints8Default exposed endpoints are /info and /health.management.endpoints.web.exposure.include=*management.endpoints.web.exposure.include=info,health,envAll endpoints are not secured by default.
  • 10.
    Secure endpoints (SpringMVC)9http.authorizeRequests().mvcMatchers("/actuator/health", "/actuator/info").permitAll().mvcMatchers("/actuator/**")
.hasRole("ACTUATOR").anyRequest().permitAll().and().httpBasic().and()...
  • 11.
    Secure endpoints (SpringMVC)9http.authorizeRequests().mvcMatchers("/actuator/health", "/actuator/info").permitAll().mvcMatchers("/actuator/**")
.hasRole("ACTUATOR").anyRequest().permitAll().and().httpBasic().and()... spring.security.user.name=hogespring.security.user.password=foospring.security.user.roles=ACTUATOR
  • 12.
    Secure endpoints (SpringMVC)10http.authorizeRequests().requestMatchers(EndpointRequest.to("health", "info")).permitAll().requestMatchers(EndpointRequest.toAnyEndpoint())
.hasRole("ACTUATOR").anyRequest().permitAll().and().httpBasic().and()...
  • 13.
    Secure endpoints (SpringWebFlux)11http.authorizeExchange().matchers(EndpointRequest.to("health", "info")).permitAll().matchers(EndpointRequest.toAnyEndpoint())
.hasRole("ACTUATOR").anyExchange().permitAll().and().httpBasic().and()...
  • 14.
  • 15.
    Cloud Foundry Support13https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/production-ready-cloudfoundry.html
  • 16.
  • 17.
    Micrometer15Move to MicrometerThinkSLF4J, but for MetricsInstrument without vendor lock-in:• Prometheus• Netflix Atlas• Datadog• InfluxDB• ...Multi-dementional metricshttps://micrometer.io/
  • 18.
    Supported monitoring systems16Serverpolls Client pushesPrometheusAtlas, Datadog, Datadog StatsD,Influx, SignalFx, Telegraf StatsD,Wavefront, New RelicDimensionalGraphite, Ganglia, JMX, Etsy StatsD,PCF Metrics 1.4Hierarchicalpushpoll
  • 19.
  • 20.
    /actuator/prometheus18system_cpu_count 4.0system_load_average_1m 1.64jvm_memory_max_bytes{area="heap",id="PSEden Space",}1.05906176E8jvm_memory_max_bytes{area="heap",id="PS Survivor Space",}2.1495808E7jvm_memory_max_bytes{area="heap",id="PS Old Gen",} 3.00941312E8http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/hello",} 4469.0http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="/hello",} 297.942920787http_server_requests_seconds_max{exception="None",method="GET",status="200",uri="/hello",} 0.401581731https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/production-ready-metrics.html#production-ready-metrics-meter
  • 21.
  • 22.
  • 23.
    On Cloud Foundry21@Bean@Profile("cloud")publicMeterRegistryCustomizer meterRegistryCustomizer(@Value("${vcap.application.name:}") String name,@Value("${vcap.application.instance_id:}") String id) {return registry -> registry.config().commonTags("cf_app_name", name,"cf_app_instance_id", id);}
  • 24.
    On Cloud Foundry22system_cpu_count{cf_app_instance_id="31388366-...",cf_app_name="demo-micrometer",}}4.0system_load_average_1m{cf_app_instance_id="31388366-...",cf_app_name="demo-micrometer",} 1.64jvm_memory_max_bytes{cf_app_instance_id="31388366-...",cf_app_name="demo-micrometer",area="heap",id="PS Eden Space",}1.05906176E8jvm_memory_max_bytes{cf_app_instance_id="31388366-...",cf_app_name="demo-micrometer",area="heap",id="PS Survivor Space",}2.1495808E7jvm_memory_max_bytes{cf_app_instance_id="31388366-...",cf_app_name="demo-micrometer",area="heap",id="PS Old Gen",} 3.00941312E8
  • 25.
  • 26.
  • 27.
    PCF Metrics25Bind MetricsForwarder Servicehttps://github.com/cloudfoundry/java-buildpack-metric-writer Use Metric Writer 2.4.0+ which comes with JBP 4.10+
  • 28.
  • 29.
  • 30.
    Histogram in Prometheus28http_server_requests_seconds_bucket{...,uri="/hello",le="0.061516456",}15646.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.067108864",} 15657.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.089478485",} 15679.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.111848106",} 15679.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.134217727",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.156587348",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.178956969",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.20132659",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.223696211",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.246065832",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.268435456",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.357913941",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.447392426",} 16475.0The number of requests that took less than 0.447392426 sec.
  • 31.
    Query percentiles inPrometheus29histogram_quantile(0.9,sum(rate(http_server_requests_seconds_bucket{status="200"}[5m])) by (app, uri, le))https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile()
  • 32.
    SLA (Service LevelAgreement)30management.metrics.distribution.sla.http.server.requests=100ms, 200ms, 400ms
  • 33.
    SLA in Prometheus31http_server_requests_seconds_bucket{...,uri="/hello",le="0.061516456",}15646.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.067108864",} 15657.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.089478485",} 15679.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.1",} 15679.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.111848106",} 15679.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.134217727",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.156587348",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.178956969",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.2",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.20132659",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.223696211",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.246065832",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.268435456",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.357913941",} 15680.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.4",} 15687.0http_server_requests_seconds_bucket{...,uri="/hello",le="0.447392426",} 16475.0
  • 34.
    Monitor user experienceby Apdex32Apdex = (Satisfied requests + Tolerating requests / 2)/ Total number of requestsSatisfied: The response time is less than or equal to T.Tolerating: The response time is greater than T and less than or equal to 4T.Frustrated: The response time is greater than 4T.https://docs.newrelic.com/docs/apm/new-relic-apm/apdex/apdex-measuring-user-satisfaction
  • 35.
    For example, T= 1.2 [sec]33Level Multiplier Time (T Example = 1.2)Satisfied T or less <= 1.2 secondsTolerating >T, <= 4T Between 1.2 and 4.8secondsFrustrated > 4T Greater than 4.8secondshttps://docs.newrelic.com/docs/apm/new-relic-apm/apdex/apdex-measuring-user-satisfaction
  • 36.
    34• During a2minute period a server handles 200 requests• T = 1.2 [sec]• 170 of the requests were handled within 1.2 sec[Satisfied]• 20 of the requests were handled between 1.2 sec and4.8 sec [Tolerating]• The remaining 10 took longer than 4.8 sec. [Frustrated]• Appdex = (170 + (20 / 2)) / 200 = 0.9For example, T = 1.2 [sec]
  • 37.
    Query Appdex (T=100ms)in Prometheus35( sum(rate(http_server_requests_seconds_bucket{le="0.1",status="200"}[5m])) by (app, uri) +sum(rate(http_server_requests_seconds_bucket{le="0.4",status="200"}[5m])) by (app, uri) )https://prometheus.io/docs/practices/histograms/#apdex-score
  • 38.
  • 39.
    Client-side Percentile37management.metrics.distribution.percentiles.http.server.requests=0.5, 0.9,0.95, 0.99, 0.999http_server_requests_seconds{...,uri="/hello",quantile="0.5",} 0.050855935http_server_requests_seconds{...,uri="/hello",quantile="0.9",} 0.051380223http_server_requests_seconds{...,uri="/hello",quantile="0.95",} 0.40265318http_server_requests_seconds{...,uri="/hello",quantile="0.99",} 0.40265318http_server_requests_seconds{...,uri="/hello",quantile="0.999",} 0.40265318
  • 40.
    Percentiles for thespecific uri in Prometheus38max(http_server_requests_seconds{uri="/hello",status="200", exception="None"}) by (quantile)
  • 41.
  • 42.
    Meter (Timer, Counter,Gauge, ...)40@Componentpublic class FooService {final Counter counter;public FooService(MeterRegistry registry) {this.counter = Counter.builder("received.messages").register(registry);}public void handleMessage() {this.counter.increment();}}Timer, Counter, Gauge, DistributionSummary, LongTaskTimer, FunctionCounter, FunctionTimer, and TimeGauge
  • 43.
    Meter (Timer, Counter,Gauge, ...)41@Componentpublic class FooService {final Timer timer;public FooService(MeterRegistry registry) {this.timer = Timer.builder("foo").register(registry);}public String foo() {return this.timer.record(() -> {// ...});}}Timer, Counter, Gauge, DistributionSummary, LongTaskTimer, FunctionCounter, FunctionTimer, and TimeGauge
  • 44.
    @Timed42@Componentpublic class FooService{@Timed("foo")public String foo() {// ...}}@Beanpublic TimedAspect timedAspect(MeterRegistry registry) {return new TimedAspect(meterRegistry);} // Not auto-configured in Spring Boot 2.0https://github.com/micrometer-metrics/micrometer/issues/361
  • 45.
    MeterFilter43@Beanpublic MeterFilter meterFilter(){return MeterFilter.deny(id -> {String uri = id.getTag("uri");return id != null && uri.startsWith("/actuator");});}Exclude metrics against Actuator endpoints
  • 46.
    Add MeterBinders44@Beanpublic HystrixMetricsBinderhystrixMetricsBinder() {return new HystrixMetricsBinder();}@Beanpublic HibernateMetrics hibernateMetrics() {return new HibernateMetrics(...);}Check io.micrometer.core.instrument.binder packageSome binders are auto-configured https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/production-ready-metrics.html#production-ready-metrics-meter
  • 47.
    Enjoy Actuator &Micrometer!45Thank you for your attention!• https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/production-ready.html• https://micrometer.io/docs• https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/production-ready-metrics.html• https://blog.ik.am/entries/448• https://github.com/making/demo-micrometer

[8]ページ先頭

©2009-2025 Movatter.jp