1 of 22

無茶振りMicrometerの話

Spring Fest 2019

Tommy Ludwig

2 of 22

3 of 22

About me

Tommy Ludwig

  • Micrometer project lead
  • Zipkin committer
  • Works at Pivotal on Spring team
  • Twitter: @TommyLudwig

4 of 22

Micrometer

  • “Think SLF4J, but for metrics.”
  • Spring Boot 2.x metrics implementation
  • Spring Boot Actuator /metrics endpoint
  • You can use Micrometer without Spring also

5 of 22

Supported backends

  • AppOptics
  • Azure Monitor
  • Netflix Atlas
  • Amazon CloudWatch
  • Datadog
  • Dynatrace
  • Elasticsearch
  • Ganglia
  • Graphite
  • Humio
  • Influx/Telegraf
  • JMX
  • KairosDB
  • New Relic
  • Prometheus
  • SignalFx
  • Google Stackdriver
  • StatsD
  • Wavefront

6 of 22

Demo Actuator

Metrics endpoint

7 of 22

Application metrics

  • Record and aggregate measurements from your application
  • Publish aggregate metrics to backend for long-term storage and analysis
  • Metadata tags to slice timeseries metric data

8 of 22

Tag / dimension / label

  • Slice metrics by tags
  • Aggregate across tags
  • Drill down metrics to specific tag value
  • Beware of cardinality!

9 of 22

Why metrics?

  • Detect problems via Alerts using near-realtime metrics
  • Analysis of problems using historical metrics
  • Lower storage cost due to data aggregation

10 of 22

Meter types

11 of 22

Gauge

  • Instantaneous value
  • Can go up and down
  • Example: CPU usage %

速度計

温度計

12 of 22

Counter

* Don’t gauge if you can count! *

  • Monotonically increasing value
  • Can calculate a rate from count over time

走行距離計

13 of 22

Timer

* Don’t count if you can time *

  • Aggregation of timed events
  • Includes at least count and total time
  • Example: HTTP endpoint response time

14 of 22

Distribution summary

  • Summarizing discrete values in buckets or percentiles.
  • Example: request body size distribution

15 of 22

Instrumentation

16 of 22

Out-of-the-box

  • HTTP server (Controller), client (RestTemplate, WebClient)
  • JVM metrics
  • Executors
  • Data clients - HikariCP, MongoDB, Kafka, RabbitMQ, Redis

17 of 22

Spring Boot and Micrometer

18 of 22

Auto-configuration

  • Add dependency on backend implementation
  • Configure with configuration properties
    • management.metrics.export.*
  • MeterBinder beans are bound to MeterRegistry beans

19 of 22

Config properties

  • management.metrics.*
  • Common tags applied to all meters
  • Percentile histograms, SLAs

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-metrics-per-meter-properties

20 of 22

Custom metrics

  • Autowire MeterRegistry and register meters
  • Useful for metrics specific to your domain
  • Published the same as auto-configured metrics
  • Be care of naming convention

21 of 22

Demo metrics backend

  • Add registry dependency
  • Confirm metrics published to backend
  • Add another, show metrics publish to both
  • Add custom metrics

22 of 22

Q & A