You are troubleshooting a performance issue in an Azure Web App. You need to write an optimized Kusto Query Language (KQL) query to find the average duration of requests grouped by the operation name. To avoid the performance impact of scanning all historical telemetry logs, you must first filter the telemetry data to only include requests from the last 6 hours.
Complete the KQL query by filling in the blanks.
Answer:requests
| where 【timestamp】 > 【ago(6h)】
| summarize AvgDuration = avg(duration) by operation_Name
| where 【timestamp】 > 【ago(6h)】
| summarize AvgDuration = avg(duration) by operation_Name
Answer
The completed query uses the 'timestamp' column and the 'ago(6h)' function to filter for the last 6 hours of requests: `requests | where timestamp > ago(6h) | summarize AvgDuration = avg(duration) by operation_Name`
The correct query begins with the 'requests' table, immediately followed by a filter on the 'timestamp' column using the 'ago(6h)' function. This filters the data to the last 6 hours before performing any aggregations, which is critical for query efficiency. The 'summarize' operator then groups the results by 'operation_Name' and calculates the average duration.
Step-by-Step Solution
Key Concept
Query optimization using time-range filters in KQL