Getting the latest/earliest value of a custom metric

Hi, I’m trying to run the following query:

SELECT latest(newrelic.timeslice.value) 
AS 'Custom/Custom/Matches/NumMatches' 
FROM Metric 
WHERE (metricTimesliceName = 'Custom/Custom/Matches/NumMatches' 
  AND 'entity.guid' = 'Mjg3NTA4N3xBUE18QVBQTElDQVRJT058MzU2MzI4MDc5') 

But I keep getting:

No value

What am I missing here? Is it not possible to get the latest value off a custom metric?

If I change latest to average, for example, I get a result.

(yes, the event name is Custom/Custom/... (i know…))

Hi @dutzi.b - Another option would be to change the query to return the top item.

SELECT newrelic.timeslice.value
AS 'Custom/Custom/ThroughputLiveScraper/NumMatches' 
FROM Metric 
WHERE (metricTimesliceName = 'Custom/Custom/ThroughputLiveScraper/NumMatches' 
  AND 'entity.guid' = 'Mjg3NTA4N3xBUE18QVBQTElDQVRJT058MzU2MzI4MDc5') 

Hey @stefan_garnham, thank you! But that returns the following:

I might be missing out something, I’m pretty new to NR so sorry for my incompetence…

Anyhow, even if that worked, what I am trying to get is the diff between the latest and the earliest, as I’m trying to present the “growth rate” of a metric, so I don’t think getting just the top item would help.

Ah, that is a different question entirely, which I do not have an answer for you. I know that earliest is actually min and I usually use these to look at timestamps.

Maybe @philweber or @6MM can provide an answer.

1 Like

I don’t know if these will work on your metric or Metric in general, but these are what you might look at with NRQL:

derivative(attribute [,time interval])

predictLinear(attribute, [,time interval])

Thanks! but it didn’t work :frowning:

I ended up with something like this, that did the job in my case, since the metric is always rising:

SELECT max(newrelic.timeslice.value) - min(newrelic.timeslice.value) 
AS `MyMetric` 
FROM Metric, Metric 
FACET appName 
WHERE (metricTimesliceName = 'Custom/Custom/ThroughputLive/NumMatches' AND appName NOT LIKE 'null') 

Hey @dutzi.b - Thanks for working this out with the community and sharing the solution you ended up with.

1 Like