概述
Metrics is a Java library which gives you unparalleled insight into what your code does in production.
Metrics provides a powerful toolkit of ways to measure the behavior of critical components in your production environment.
With modules for common libraries like Jetty, Logback, Log4j, Apache HttpClient, Ehcache, JDBI, Jersey and reporting backends like Ganglia and Graphite, Metrics provides you with full-stack visibility.
Dropwizard Metrics 能夠幫助我們從各個角度度量已存在的java應用的成熟框架,簡便地以jar包的方式集成進您的系統(tǒng),可以以http、ganglia、graphite、log4j等方式提供全棧式的監(jiān)控視野。
Metrics 類型
度量術語 | 描述 |
---|---|
Meters | Meter度量一系列事件發(fā)生的速率(rate),例如TPS。Meters會統(tǒng)計最近1分鐘,5分鐘,15分鐘,還有全部時間的速率。 |
Gauges | 某個特定瞬時值,例如MQ中消息數(shù)量 |
Counters | Counter 就是計數(shù)器,Counter 只是用 Gauge 封裝了 AtomicLong |
Histograms | Histogram統(tǒng)計數(shù)據(jù)的分布情況。比如最小值,最大值,中間值,還有中位數(shù),75百分位, 90百分位, 95百分位, 98百分位, 99百分位, 和 99.9百分位的值(percentiles)。 |
Timers | Timer其實是 Histogram 和 Meter 的結(jié)合, histogram 某部分代碼/調(diào)用的耗時, meter統(tǒng)計TPS。 |
Health Checks | 集中式檢測系統(tǒng)的監(jiān)控狀態(tài),例如數(shù)據(jù)庫連接是否正常。 |
Reporting | 度量值可以通過 HTTP,SLF4J,JMX,CSV ,Ganglia,Graphite |
使用
Maven依賴
<dependencies>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>${metrics.version}</version>
</dependency>
</dependencies>
目前Metrics的最新版本是** 3.2.4 **。