An Azure App Service web application experiences performance degradation due to slow external HTTP dependency calls. You need to write a Kusto Query Language (KQL) query in Application Insights to identify the top three external dependencies that failed in the last 24 hours, sorted by their average duration, along with the total count of failures for each dependency. The query must be optimized for performance and scan the minimum amount of data.
Which KQL query should you use?
- Arequests
| where success == false
| summarize AvgDuration = avg(duration), FailureCount = count() by name
| top 3 by AvgDuration desc - Bdependencies
| where success == false
| summarize AvgDuration = avg(duration), FailureCount = count() by name
| top 3 by AvgDuration desc - dependencies
| where timestamp > ago(24h) and success == false
| summarize AvgDuration = avg(duration), FailureCount = count() by name
| top 3 by AvgDuration descCevap - Ddependencies
| where success == false
| summarize AvgDuration = avg(duration), FailureCount = count() by name
| top 3 by AvgDuration desc
| where timestamp > ago(24h)
Cevap
The correct query filters the dependencies table by timestamp and success status first, then summarizes the average duration and count of failures by name, and finally selects the top 3 by average duration descending.
The query filtering by timestamp and success at the very beginning of the pipeline is correct because it limits the scope of the telemetry records before aggregation, optimizing query performance. It utilizes the dependencies table to analyze outgoing calls and aggregates by name using avg(duration) and count() to calculate average duration and total failures respectively.
Adım Adım Çözüm
Anahtar Kavram
Querying and optimizing Application Insights telemetry using KQL by applying early time filters