Search code examples
azureazure-application-insightsazure-log-analytics

Azure Log Analytics query if property exists


I am trying to check if my customDimensions object has a property and then only count the queries that have the property set to something. It is counting queries that don't have the SupportedLanguage property in the customDimensions object.

Here is my current query:

customEvents
| where timestamp > ago(7d)
| summarize COUNT=count(customDimensions.SupportedLanguage) by lang=tostring(customDimensions.SupportedLanguage)
| render piechart

I tried doing the following but it didn't work:

customEvents
| where timestamp > ago(7d)
| where customDimensions.SupportedLanguage
| summarize COUNT=count(customDimensions.SupportedLanguage) by lang=tostring(customDimensions.SupportedLanguage)
| render piechart 

Solution

  • You can leverage isnotempty() function for this purpose:

    customEvents
    | where timestamp > ago(7d)
    | where isnotempty(customDimensions.SupportedLanguage)