An enterprise order processing application sends custom metric telemetry to Azure Application Insights to monitor message queue sizes. A custom metric named 'QueueBacklog' is recorded, and the specific queue's identifier is stored inside a custom dimension named 'QueueName'.
You need to write a Kusto Query Language (KQL) query to find the maximum backlog value for each queue over the last 36 hours. To ensure optimal query performance, you must filter by time range before performing any other operations.
How should you complete the KQL query?
Answer:kusto
【customMetrics】
| where timestamp > ago(36h) and name == "QueueBacklog"
| extend QueueName = 【tostring】(customDimensions.QueueName)
| summarize MaxBacklog = 【max】(value) by QueueName
【customMetrics】
| where timestamp > ago(36h) and name == "QueueBacklog"
| extend QueueName = 【tostring】(customDimensions.QueueName)
| summarize MaxBacklog = 【max】(value) by QueueName
Answer
To complete the query, query the 'customMetrics' table first to load custom metric telemetry, then use the 'tostring' function to cast the dynamic custom dimension property to a string, and finally use the 'max' aggregation function to find the maximum backlog value.
The query starts by targeting the 'customMetrics' telemetry table. To ensure optimization, the time-range filter is applied immediately using the 'where' clause, which restricts processing to the last 36 hours. The dynamic property 'customDimensions.QueueName' is cast to a string type using the 'tostring' function. Finally, the 'max' aggregation function calculates the highest backlog value recorded in the 'value' column, grouping the results by the queue name.
Step-by-Step Solution
Key Concept
Querying custom metrics and dimensions in Application Insights using optimized KQL filters and aggregations.
Estimated Time:2m 0s