Counting latest(feature_status)

We have a number of devices that report to New Relic, and these devices each have a number of features that can be enabled or disabled at any time (per device). To track which features are enabled per-device, we have a ‘heartbeat’ setup which reports the status of each feature every 30 minutes. We are displaying these statuses with the following query:

SELECT latest(timestamp), latest(featureA), latest(featureB) FROM DeviceReportingEvent WHERE action='feature_status' FACET deviceId

featureA and featureB will either be true or false for enabled/disabled.

I would like to create a widget which counts how many devices have reported the latest status of featureB as being enabled (true) to get a count of which devices have featureB enabled.

Is there any easy way to do this?

Hey @michael.chovan

Does something like this work:

SELECT count(*) FROM DeviceReportingEvent WHERE featureB = 'True' SINCE 30 MINUTES AGO

This counts over 30 minutes the amount of times featureB comes in with True

Hi Ryan, thanks for the response!

After tinkering around, I think I came up with the solution I’m looking for, just need to do a little more testing.

SELECT uniqueCount(deviceId) from DeviceReportingEvent WHERE action='feature_status' AND featureB IS TRUE SINCE  30 minutes ago
1 Like

That query looks good! :smiley: