Question

Difficulty: EasyQuery and Analyze Application Insights Telemetry

You are troubleshooting a performance issue with a Kusto Query Language (KQL) query used to retrieve telemetry from Application Insights. The query currently looks like this:

kql
requests
| where success == false
| summarize count() by bin(timestamp, 1h)

The query is taking a long time to run and occasionally exceeds resource limits because it scans all historical data.

Which of the following changes should you make to the query to improve performance and prevent resource limit issues?

  1. Add a where clause filtering by a timestamp range (e.g., | where timestamp > ago(24h)) immediately after the requests table.Answer
  2. B
    Add a where clause filtering by a timestamp range (e.g., | where timestamp > ago(24h)) as the last line of the query after the summarize operator.
  3. C
    Add a take 100 clause at the end of the query to limit the number of returned rows.
  4. D
    Ensure that the Application Insights SDK connection string is configured in the query settings.

Answer

Add a where clause filtering by a timestamp range (e.g., | where timestamp > ago(24h)) immediately after the requests table.
Filtering by timestamp early in the query pipeline restricts the dataset size processed by subsequent operators. In this query, adding the time filter immediately after the requests table ensures the query engine only scans the last 24 hours of data, preventing slow execution times and resource limit exhaustion.

Step-by-Step Solution

1
Analyze the KQL query pipeline structure.
The query starts with the requests table, applies a success filter, and then summarizes the data.
Understanding the pipeline order is crucial because KQL executes operations sequentially.
2
Identify the performance bottleneck in the query.
The query lacks a time-range boundary, forcing Azure Monitor to scan the entire historical telemetry database.
Restricting the time range is the single most effective way to optimize telemetry queries.
3
Determine the optimal position for the time filter.
Placing '| where timestamp > ago(24h)' immediately after 'requests' ensures that only data from the last 24 hours is loaded into subsequent operators.
Filtering early reduces the volume of data processed by downstream operators like summarize.

Key Concept

KQL Query Optimization with Time-Range Filters
Estimated Time:1m 0s
Rate this question