Soru

Zorluk: OrtaQuery and Analyze Application Insights Telemetry

You need to write an optimized Kusto Query Language (KQL) query that returns the average duration of failed dependency calls grouped by target for the last 12 hours. The query must be optimized to filter the data as early as possible. How should you complete the KQL query to satisfy these requirements? Complete the query by filling in the missing KQL operators and fields in the blanks.

Cevap:dependencies
| 【where】 timestamp > ago(12h)
| where 【success】 == false
| 【summarize】 AverageDuration = avg(duration) by target

Cevap

The completed query uses the 'where' operator to filter by timestamp first, the 'success' property to filter for failed dependency calls, and the 'summarize' operator to compute the average duration by target.
The query starts with the 'dependencies' table. It filters for records from the last 12 hours using '| where timestamp > ago(12h)' to ensure the query remains optimized. Next, it filters for unsuccessful calls using '| where success == false'. Finally, it groups the results and calculates the average duration using '| summarize AverageDuration = avg(duration) by target'.

Adım Adım Çözüm

1
Filter the dataset by time range immediately after referencing the telemetry table.
Using the 'where' operator to filter 'timestamp > ago(12h)' minimizes the query scope.
In KQL, filtering by timestamp as early as possible prevents scanning unnecessary historical logs, optimizing performance.
2
Filter specifically for dependency calls that failed.
Reference the boolean column 'success' and check if its value is false.
The Application Insights dependencies table represents execution success via the 'success' boolean property.
3
Summarize the average duration grouped by target.
Use the 'summarize' operator and the 'avg' aggregation function.
The 'summarize' operator groups data by specified columns and aggregates target metrics.

Anahtar Kavram

Writing optimized KQL queries on Application Insights telemetry by applying early time filters and performing aggregations.
Tahmini Süre:1m 30s
Bu soruyu puanla