Giter Club home page Giter Club logo

metrics-new-relic's Introduction

This library provides a reporter for Metrics that writes to New Relic.

Each of the main types of Metrics (Gauges, Counters, Histograms, Meters, Timers) have all available data (percentiles, min, max, etc. as applicable) reported as "custom metrics" in New Relic.

Usage

To upload all metrics in your MetricRegistry with all available data (not filtering at all), this will do:

NewRelicReporter reporter =
        new NewRelicReporter(registry, "new relic reporter", MetricFilter.ALL,
            new AllEnabledMetricAttributeFilter(), TimeUnit.SECONDS, TimeUnit.MILLISECONDS,
            "");
reporter.start(1, TimeUnit.MINUTES);

This will report all attributes of all metrics to New Relic using seconds as the rate unit and milliseconds as the duration unit. Data will be reported via the New Relic Java API once a minute.

Custom metrics in New Relic

As an example, a Histogram would have the following custom metrics recorded:

  • Custom/metricName/75th
  • Custom/metricName/95th
  • Custom/metricName/98th
  • Custom/metricName/99th
  • Custom/metricName/99.9th
  • Custom/metricName/min
  • Custom/metricName/max
  • Custom/metricName/mean
  • Custom/metricName/median
  • Custom/metricName/stdDev

A Timer would have the above attributes as well as the various calculated rates, like:

  • Custom/metricName/15MinuteRate/second

In this case, the trailing second means that the rate unit is set to seconds.

You can then proceed to use those metrics in New Relic custom dashboards.

You can also specify a non-empty metric name prefix if you wish to further segregate your various metrics. With a prefix of foo/, your metrics would appear as Custom/foo/metricName/max, for instance.

Limiting what's reported to New Relic

According to New Relic's custom metric best practices, they want to keep the number of custom metrics under 2000 or so. Since each Timer might generate a dozen custom metrics in New Relic, it's pretty easy to hit this limit.

There are two ways you can keep the number of custom metrics under control. To choose which specific metrics to report on, use a MetricFilter. If you want to report on all metrics, use MetricFilter.ALL; otherwise, provide your own implementation of MetricFilter.

To limit which attributes of each metric will be reported to New Relic, MetricAttributeFilter has boolean methods for every attribute, such as boolean recordTimerMedian(String name, Timer metric). All such methods will be passed the metric name and the metric object itself for arbitration on whether or not the relevant attribute will be reported. For convenient implementation of both whitelist and blacklist approaches, AllEnabledMetricAttributeFilter and AllDisabledMetricAttributeFilter are provided.

metrics-new-relic's People

Contributors

alaz avatar

Watchers

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