LLI Wiki — My Digital Knowledge Base

KQL: find the accounts hit hardest by latency in Application Insights

KQL queries on the requests table and performanceBucket to spot slow requests per account.

KQL queries for Application Insights (the requests table) to find the accounts or users suffering from latency. The performanceBucket column classifies each request by duration (<250ms, 250ms-500ms, 500ms-1sec, 1sec-3sec, 3sec-7sec, ...). Open the Application Insights resource, then Logs.

Slow requests over time, by account

requests
| where performanceBucket in ("3sec-7sec","1sec-3sec")
| summarize count() by bin(timestamp,5m),user_AccountId
| render timechart

Slow request breakdown for one account

requests
| where user_AccountId == "account01"
| where performanceBucket !in ("<250ms","250ms-500ms","500ms-1sec")
| summarize count() by bin(timestamp,5m),performanceBucket
| render timechart

Top 5 accounts with the most slow requests

requests
| where performanceBucket !in ("<250ms", "250ms-500ms", "500ms-1sec")
| summarize BadPerformanceCount = count() by user_AccountId
| top 5 by BadPerformanceCount
| project user_AccountId;

Slow requests over time for those 5 accounts

let Top5Users = requests
    | where isnotempty(user_AccountId)
    | where performanceBucket !in ("<250ms", "250ms-500ms", "500ms-1sec")
    | summarize BadPerformanceCount = count() by user_AccountId
    | top 5 by BadPerformanceCount
    | project user_AccountId;
requests
    | where isnotempty(user_AccountId)
    | where user_AccountId in (Top5Users)
    | where performanceBucket !in ("<250ms", "250ms-500ms", "500ms-1sec")
    | summarize Count = count() by bin(timestamp, 10m), user_AccountId, performanceBucket
    | render timechart

Isolate a time window

let StartTime = datetime(2025-01-20T08:00:00Z);
let EndTime = datetime(2025-01-20T10:00:59Z);
requests
| where performanceBucket == "1sec-3sec"
| where user_AccountId == "account01"
| where timestamp >= StartTime and timestamp <= EndTime

To analyse the requests themselves, then use Transaction search in the resource menu.

Screenshots

Application Insights Logs blade: KQL queries and a chart of slow requests per account

Mastodon LLIMastodon SocialFosstodon