This is a CloudWatch Reporter for the stable version of Dropwizard Metrics (formerly CodaHale & Yammer Metrics). The reporter is an implementation of ScheduledReporter from Dropwizard Metrics v3.2.2
- Java 1.8
- This CloudWatchReporter reports the metric data to CloudWatch asynchronously using the AmazonCloudWatchAsyncClient (AWS) interface
- Each reportable value in CodeHale Metric is reported as a separate MetricDatum (AWS)
- When reporting Meter, Counter, Histogram and Timer count metrics (
getCount()
) as MetricDatum (AWS), only the count difference since the last report is reported. This way the counters do not require a reset within the application using this reporter. - If configured, each Snapshot translated into StatisticSet (AWS) in the most direct way possible.
- If configured, JVM statistic is reported
Currently the only metric values that are reportable through configuration are:
- Values of type
Number
from Gauge - Counts from Counter, Histogram, Meter and Timer
- Percentiles from Snapshot in Histogram and Timer
- Arithmetic mean & standard deviation of Snapshot values in Histogram and Timer
- Mean rates from Meter and Timer
- Summaries of Snapshot values in Histogram and Timer as StatisticSet (AWS)
The Reporter uses the following defaults which can be configured:
- Rate metrics are in
TimeUnit.Seconds
- Duration metrics are in
TimeUnit.Milliseconds
MetricFilter.ALL
will be used for the FilterClock.defaultClock()
will be used for the Clock (Unconfigurable)- Empty global Dimension (AWS) list
- The reporter adds a
Type
Dimension (AWS) to each reported metric, e.g:
Type | Metric Name |
---|---|
1-min-mean-rate [per-second] | com.example.component.SomeComponent.timer |
snapshot-mean [in-milliseconds] | com.example.component.SomeComponent.timer |
snapshot-mean | com.example.component.SomeComponent.histogram |
95% | com.example.component.SomeComponent.timer |
99.5% | com.example.component.SomeComponent.timer |
99.5% | com.example.component.SomeComponent.histogram |
count | com.example.component.SomeComponent.counter |
The only metrics that are reportable by default are:
- Count values (
getCount()
) from Meter, Counter, Histogram and Timer - Percentile values (
75%
,95%
,99.9%
) from Histogram and Timer
All other metrics have to be confugured for reporting by invoking their respective withXXXX()
methods on the CloudWatchReporter.Builder
instance
Gradle
repositories {
mavenCentral()
}
dependencies {
compile("io.github.azagniotov:dropwizard-metrics-cloudwatch:1.0.3")
}
The library fetches the following transitive dependencies:
io.dropwizard.metrics:metrics-core:3.2.2
io.dropwizard.metrics:metrics-jvm:3.2.2
com.amazonaws:aws-java-sdk-cloudwatch:1.11.114
com.google.guava:guava:21.0
The reporter provides a fine-grained configuration options through its builder to configure what metrics should be reported to CloudWatch. Since AWS costs money, you probably do not want to report all
the values from Metric classes or Snapshot, but only what's really useful to you.
final AmazonCloudWatchAsync amazonCloudWatchAsync = new AmazonCloudWatchAsyncClient();
amazonCloudWatchAsync.setRegion(Region.getRegion(Regions.US_WEST_2));
final CloudWatchReporter cloudWatchReporter =
CloudWatchReporter.forRegistry(metricRegistry, amazonCloudWatchAsync, Main.class.getName())
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.filter(MetricFilter.ALL)
.withPercentiles(Percentile.P75, Percentile.P99)
.withOneMinuteMeanRate()
.withFiveMinuteMeanRate()
.withFifteenMinuteMeanRate()
.withMeanRate()
.withArithmeticMean()
.withStdDev()
.withStatisticSet()
.withJvmMetrics()
.withGlobalDimensions("Region=us-west-2", "Instance=stage")
.withDryRun()
.build();
cloudWatchReporter.start(10, TimeUnit.SECONDS);
The reporter can be configured to run in DRY RUN
mode by invoking .withDryRun()
on the Builder
. In that case, the reporter will log.DEBUG
the created instance of PutMetricDataRequest (AWS), instead of doing a real POST
to CloudWatch.
- https://github.com/blacklocus/metrics-cloudwatch
- https://github.com/tptodorov/metrics-cloudwatch
- https://github.com/basis-technology-corp/metrics-cloudwatch-reporter
- https://github.com/wavefrontHQ/java/tree/master/dropwizard-metrics/3.1
MIT