An Azure App Service web application logs performance and error telemetry to an Azure Application Insights resource. You need to write a Kusto Query Language (KQL) query to retrieve the top 10 slowest external dependency calls based on their average duration over the past 24 hours. The results must only include dependencies associated with failed web requests. To prevent query performance degradation and avoid scanning excessive telemetry data outside the target window, the query must be optimized. Which KQL query should you execute?
- let failed_requests = requests
| where timestamp > ago(24h) and success == false
| project operation_Id;
dependencies
| where timestamp > ago(24h)
| join kind=inner failed_requests on operation_Id
| summarize AvgDuration = avg(duration) by name
| top 10 by AvgDuration descCevap - Blet failed_requests = requests
| where success == false
| project operation_Id;
dependencies
| where timestamp > ago(24h)
| join kind=inner failed_requests on operation_Id
| summarize AvgDuration = avg(duration) by name
| top 10 by AvgDuration desc - Clet failed_requests = requests
| where timestamp > ago(24h) and success == false
| project operation_Id;
dependencies
| join kind=inner failed_requests on operation_Id
| summarize AvgDuration = avg(duration) by name
| top 10 by AvgDuration desc - Drequests
| join kind=inner dependencies on operation_Id
| where timestamp > ago(24h) and success == false
| summarize AvgDuration = avg(duration) by name
| top 10 by AvgDuration desc
Cevap
The query that filters both the requests and dependencies tables by timestamp greater than 24 hours ago before joining them on the operation_Id field, and then summarizes the average duration grouped by name to return the top 10 results.
The correct query applies the timestamp filter to both the requests table and the dependencies table before performing the join. In KQL, filtering all joined tables by time restricts the scanned dataset size on both inputs, ensuring maximum query efficiency and preventing timeouts.
Adım Adım Çözüm
Anahtar Kavram
Optimizing KQL queries in Azure Application Insights by applying time-range filters to both sides of a join operation to minimize resource consumption.