This library provides a reporter for Metrics that writes to New Relic Insights.
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.
You can build the project with the following command:
./gradlew clean build
Reference the Jar like this in your gradle build file:
dependencies {
compile(
"com.nike.metrics:metrics-new-relic-insights:1.8"
)
}
Set up your MetricRegistry
like this:
NewRelicInsightsReporter reporter = NewRelicInsightsReporter.forRegistry(registry)
.name("New Relic Metrics")
.filter(MetricFilter.ALL)
.rateUnit(TimeUnit.SECONDS)
.durationUnit(TimeUnit.MILLISECONDS)
.metricNamePrefix("")
.build();
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 Agent once a minute.
The metrics reporter will be recognized by Insights as Custom Metrics and will look something like this in your data explorer:
Things like timers and Gauges have multiple attributes. In Insights these will be represented as attributes to the metric which you can see in your data explorer like this:
Insights has some metric naming restrictions, you should read about them here.