Giter VIP home page Giter VIP logo

codahale-aggregated-metrics-cloudwatch-reporter's Introduction

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.3

Table of Contents

Prerequisites

  • Java 1.8

Summary

Reportable Metrics

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

Please note:

  • Histogram values (the percentiles, min, max, sum, arithmetic mean & std-dev from Snapshot) are reported raw.
  • Timer values (the percentiles, min, max, sum, arithmetic mean & std-dev from Snapshot) are reported after conversion by a duration factor was applied. The duration factor is calculated by converting 1 unit of duration unit type to nanoseconds (see ScheduledReporter)
  • Meter values (the 1min rate, 5min rate, 15min rate & mean rate) are reported after conversion by a rate factor was applied. The rate factor is calculated by converting 1 unit of rate unit type to seconds (see ScheduledReporter)

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.5")
}

The library fetches the following transitive dependencies:

    io.dropwizard.metrics:metrics-core:3.2.3
    io.dropwizard.metrics:metrics-jvm:3.2.3
    com.amazonaws:aws-java-sdk-cloudwatch:1.11.179
    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 =
            AmazonCloudWatchAsyncClientBuilder
                    .standard()
                    .withRegion(Regions.US_WEST_2)
                    .build();
    
    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

Changelog

1.0.5

  • Upgraded Metrics to v3.2.3 due to #1115
  • Upgraded AWS Java SDK to v1.11.179

1.0.4

  • Issue #4: Not reporting metric zero values.
  • PR #6: Reporting Histogram snapshot raw values as StatisticSet, without applying a conversion by duration factor (https://github.com/williedoran)
  • Checking isDebugEnabled when logging debug information

1.0.3

1.0.2

  • PR #2: Updated AWS SDK to com.amazonaws:aws-java-sdk-cloudwatch:1.11.86 (https://github.com/MeiSign)
  • Reporting Histogram snapshot Arithemtic Mean & StdDev raw values, without applying a conversion by duration factor

1.0.1

  • Revisited Javadoc
  • Added dependency on metrics-jvm module in order to be able to export JVM metrics
  • Code clean-up

1.0.0

  • Initial release

License

MIT

codahale-aggregated-metrics-cloudwatch-reporter's People

Contributors

azagniotov avatar efenderbosch avatar meisign avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.