NRQL selects columns/ fields that are not part of the event type

Recently I have noticed that I am able to select columns/ fields
that are not part of my Eventtypes/ tables in New Relic.
When I run a query to retrieve the keyset() from this eventtype,
it returns only those columns/fields that are part of that particular eventtype.

Greatly appreciate if someone could explain why I am able to select
columns/ fields that does not exists in an event type/table.

Can you give an example?

Keyset() can return different sets of attributes for the same event type based on the time window or some filter. It would depend on things like agent, OS, custom attributes etc.

1 Like

Hi @pp723t looking forward to your response!

Hello @CommunityHero

I agree with you, the keyset() will depend on the attributes you mentioned above. My question was a bit more generic like this sample select statement:
SELECT hello, hi, randomcols from ProcessSample
these columns don’t exist but this select statement does not throw back an error, it gives me result with “null” data. I am not concerned about the NULL data, just curious on how the select works with these invalid columns

Ok, so what’s the point of using invalid columns? Are you just wondering why its not helping you with spelling errors and copy/paste problems?

I suppose there is probably a reason. Could be handy if you wanted an empty column. The likely explanation kind of goes back to the fact that you can have custom attributes and they can be infrequent. How would the NRQL query know your attribute is wrong? Wrong this hour? This day? This month?

3 Likes

Thank you @communityHero! This helps!
I was just curious on why NR doesn’t throw an error when we select columns that does not exist.

I think I can help shed some light on this… NRDB is schema-less, which means that any event/metric type can have any named attribute. Querying follows this pattern, so it’s possible to look for any attributes on any event/metric. NRDB will treat this as a genuine query and will attempt to look for any attribute/s matching your query. The autocomplete function in Query Builder is designed to help you avoid typos, or you can use Data Explorer to visually find attributes and build your NRQL queries.

If you are familiar with relational databases this seems like a strange concept, but it’s for good reason - the flexibility of NRDB means you can add custom attributes on the fly and don’t need to worry about data migration, normalization, etc. You may be interested in this white paper which goes into more detail: https://newrelic.com/resources/white-papers/inside-nrdb-flexible-unified-database

2 Likes