ARTICLE AD BOX
I'm working with the New Relic Java agent and trying to record a simple custom metric using recordMetric.
My use case is very straightforward: I want to track something like "transactions per second" or any simple integer-based metric.
Here is a simplified version of what I'm doing:
public String simpleFunction() { Random ran = new Random(); NewRelic.recordMetric("Custom/TestData/RequestsPerSecond", ran.nextInt(10, 100)); return "Hi"; }This function represents my actual implementation, just simplified.
The issue is that this does not seem to work — I don't see any custom metric data in New Relic at all.
Important context:
The New Relic agent is correctly configured.
Data is being sent successfully using other APIs:
recordCustomEvent
noticeError
I can see those in New Relic without any issues.
I've followed the naming guidelines for custom metrics (Custom/...).
However, nothing shows up for this metric.
I've also tried querying it using NRQL:
SELECT * FROM Metric WHERE metricTimesliceName LIKE 'Custom/TestData%' SELECT average(newrelic.timeslice.value) FROM Metric WHERE metricTimesliceName = 'Custom/TestData/RequestsPerSecond' SINCE 30 minutes ago TIMESERIES SELECT average(newrelic.timeslice.value) FROM Metric WHERE metricTimesliceName = 'Custom/TestData/RequestsPerSecond' SINCE 1 hour agoI even tried browsing metrics manually, value by value, and still nothing appears.
I understand that there are built-in APM approaches to derive metrics like throughput automatically, but in this case I specifically want to record it manually using recordMetric.
Question:
Why is recordMetric not producing any visible data in New Relic, even though the agent is working correctly for other features?
