How to use Application Insights Custom Properties in Azure Monitor Log (Kusto) Queries

Azure Application Insights is great for easily adding telemetry to your application across a variety of languages (.Net web apps, Azure functions, .Net Framework / Core apps, JavaScript SPAs and more). The telemetry is logged back to an Application Insights instance in your Azure tenant. You can then view all the reported telemetry via the Azure Portal. I’m not going to cover the basics, you can check it all out in the Microsoft documentation.

What I wanted to cover was custom properties. These are great for adding more than just a simple message when logging events from your application. If there is specific data that you want to collect telemetry for, then custom properties can be used to capture multiple key/value pairs in a single telemetry event.

TrackTrace with custom properties
This code creates a Dictionary of custom properties that we can include in the TrackTrace (or other telemetry event types)

When viewing the resulting telemetry event in Application Insights via the Azure Portal you can see the custom properties are now displayed in the event data.

Custom properties shown in Application Insights
Custom properties shown in Application Insights

All pretty simple so far right? The next logical thing you will want to do with your custom properties is to query/report on them across many sessions to see what’s happening across all of your users/sessions. For this we step into Azure Monitor Log Queries and we write queries over the same data set that we were navigating via the Application Insight GUI. The language used is Kusto.

Below shows the same event but this time as the result of a Kusto query.

Notice that our custom properties appear as a column called customDimensions. I can’t explain why they are called custom properties in Application Insights and custom dimensions in these queries, it’s inconsistent but that’s just how it works. But our bigger issue is that the custom dimensions are all lumped together in one column. This doesn’t make it easy use the data in queries. Imagine we wanted to select all items where the FirstName custom dimension is “Cat”, because all the key value pairs are lumped together in one column value we can’t directly write this query.

The solution is to first use the extend operator to extract our custom dimensions and promote them to columns in their own right. Once you have these as their own columns they can then be used like other column values. As shown in the query below this allows us to write a query to select just the items where the FirstName custom dimension is “Cat”.

Custom dimensions extended to be columns

Continue reading the follow up article on on dumping entire complex objects to Application Insights as serialized JSON and then deserializing for reporting 💥

One thought on “How to use Application Insights Custom Properties in Azure Monitor Log (Kusto) Queries

Add yours

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a website or blog at

Up ↑

%d bloggers like this: