Question

Difficulty: MediumQuery and Analyze Application Insights Telemetry

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

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

1
Identify the time-range column in the Application Insights telemetry tables.
The 'timestamp' column represents the date and time when the telemetry record was logged.
All telemetry tables in Application Insights (such as requests, dependencies, exceptions) use the 'timestamp' column for tracking log entry times.
2
Select the appropriate KQL timespan function to calculate the date and time offset for 6 hours ago.
The 'ago(6h)' function returns the datetime value relative to the current UTC time minus 6 hours.
Filtering on timestamp with 'ago()' ensures that only records within the specified window are scanned, preventing expensive full-table scans.

Key Concept

Query optimization using time-range filters in KQL
Rate this question