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.
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.
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”.
Continue reading the follow up article on on dumping entire complex objects to Application Insights as serialized JSON and then deserializing for reporting 💥