Skip to content

williedoran/codahale-aggregated-metrics-cloudwatch-reporter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodaHale Aggregated Metrics CloudWatch Reporter

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

Table of Contents

Prerequisites

  • Java 1.8

Summary

Reportables

Currently the only metric values that are reportable through configuration are:

Defaults

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 Filter
  • Clock.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:

All other metrics have to be confugured for reporting by invoking their respective withXXXX() methods on the CloudWatchReporter.Builder instance

Dependencies

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

Usage

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);

Dry run

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.

Credits

License

MIT

About

ScheduledReporter implementation from Codahale Metrics to Amazon CloudWatch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%