Multiple Metrics from Multiple Event Tables

How do I NRQL from multiple metrics from multiple event tables? I need to generate a table that shows cpuPercent and memoryUsedPercent from SystemSample and diskUserPercent from StorageSample. I could use just SystemSample, but I have been using StorageSample for diskUserPercent and everywhere and the values are different. So I need to stick to StorageSample for the diskUserPercent metric, unfortunately.

Any suggestion on how to get a table like that?

Thanks

SELECT average(cpuPercent), average(memoryUsedPercent), average(diskUsedPercent) 
FROM SystemSample, StorageSample FACET hostname
1 Like

By the way, if you have not already done so, I recommend that you deploy the free NRQL Lessons app to your account and go through the lessons to learn NRQL.

1 Like

Hi @philweber that looks perfect. I get the right numbers. I am just curious how it decides to pick the diskUsedPercent from StorageSample and not from SystemSample. Also thanks for the suggestion on the NRQL lessons app. I will definitely go over it.

Thanks again!
Asif

When I remove StorageSample from the query, I do not get any values for diskUsedPercent. I assume the query parser uses the values from StorageSample because SystemSample has no values.

If you have attribute name collision between event types (since you can have custom attributes and custom events) you can use filter() in the select like this:

filter(count(*), where eventType() = 'SystemSample')

3 Likes

Hey @philweber I do have diskUsedPercent on both SystemSample and StorageSample. However it does pick the value from StorageSample when that event table is added in NRQL like you showed earlier. I will still try to use filter option may be like @6MM explained.

Thanks,
Asif

I think this would be really useful as an example on the NRQL library @6MM :slight_smile:

1 Like