Full stack dev🧑🏻‍💻

Query multiple Application Insights instances with KQL (Kusto Query Language)

Posted

1 min read

Let's say you have multiple different Application Insights instances across different regions, resource groups or whatever. Quite recently, I had the need to query multiple application insights instances to be able to count the number of a certain custom event I had. There was at least two different application insights instances that I needed to query, and here is a simple example of how you can achieve the same.

You can query across workspaces, and across AI instances, and in this sample I'll show you how you can query by just using the name of you Application Insights instance (used in the "app" function).

Go to your application insights instance, and copy the name of it so it can be used in the query.

The example query below shows how you can use two different application insights instances in the same query and counting the total number of custom events for the past 31 days across both instances.

union app("myFirstInstance").customEvents, app("mySecondInstance").customEvents | where timestamp > ago(31d) | summarize NumberOfEvents=sum(itemCount)

You can read more about querying across workspaces, applications and resources here https://learn.microsoft.com/en-us/azure/azure-monitor/logs/cross-workspace-query.

Isa
Isa

More Stories

Cover Image for C# Cosmos DB simple "lock" functionality by implementing Optimistic Concurrency Control

C# Cosmos DB simple "lock" functionality by implementing Optimistic Concurrency Control

Prevent data corruption when multiple users concurrently try to update a single Cosmos DB item in an Azure Function. Implement optimistic concurrency control using ETags and retry logic to ensure correct updates....

Cover Image for Exploring the Power of Kusto Query Language in Azure Application Insights

Exploring the Power of Kusto Query Language in Azure Application Insights

In this blog post we will look into a few samples of Kusto queries. The purpose of this is to get familiar with how queries look like and how they can be tested out in the Azure portal....