Search code examples
monitoringnewrelic

NewRelic: HOWTO get only the LAST data per FullHostName (Regardless of when queried)


In New Relic Infrastructure monitoring (not alerting) I am trying to get the latest CPU and Memory, per FullHostName:

SELECT fullHostname,processorCount,memoryTotalBytes/1073741824 from SystemSample where fullHostname LIKE 'serverconvention%' COMPARE WITH 1 week ago

When the above runs I get only 10 servers out of hundreds. When I run the below choice I get more than 20 entries per server:

SELECT fullHostname,processorCount,memoryTotalBytes/1073741824 from SystemSample where fullHostname LIKE 'serverconvention' COMPARE WITH 1 week ago LIMIT Max

So how do I limit the data to only ONE set of values PER FullHostName, only the LATEST data (regardless of when the latest data came in)?


Solution

  • I think you want something like this:

    SELECT latest(processorCount), latest(memoryTotalBytes)/1073741824 FROM SystemSample where fullHostname LIKE 'serverconvention%' facet fullHostname COMPARE WITH 1 week ago LIMIT MAX

    This will give you the latest processorCount/memory + faceting is essentially grouping - so that should break it down for each unique host you are targeting.