NRQL returns no results unless another attribute is included

Hey NRQL experts,

I’m trying to build a query to use in an alert. My goal is to subtract database.disk.bytesused from database.disk.quota which works … as long as I include ANY other attribute in the SELECT ? If the SELECT only includes the difference then NR fails to return any data. What am I missing?



Hi @bdudley,

To accomplish what you need, you’ll need to query the individual attributes in a subquery, and then do the computation. This should work for you:

SELECT (latest(quota) - latest(bytesUsed)) as 'diff' FROM (SELECT latest(database.disk.Quota) as 'quota', latest(database.disk.BytesUsed) as 'bytesUsed' FROM GcpCloudSqlSample  FACET entityId WHERE label.stack = 'production')  FACET entityId
1 Like