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 💥


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

Add yours

  1. Application Insights acts as middleware for many types of actions. In your example the firstName, lastName properties would be added to all telemetry. What if you want to add those properties only to specific actions, for example: Page Visits but not SQL queries.


    1. While you can apply custom metrics to all types of telemetry collected, the example code in the article actually just applies the custom properties to that single Trace call. No other Trace calls (or any other types of telemetry events) would get those custom properties applied. To have custom properties recorded on all events then the best approach is to use Telemetry Initializers

      Telemetry Initializers should give you the ability to conditionally add the custom properties to just those calls that you want. I hope this helps, let me know how you get on.


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 )

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: