AZ-204 Practice Question: Monitor, troubleshoot, and optimize Azure solutions
You are monitoring an Azure web app using Application Insights. You need to create a query that returns the average duration of requests for each HTTP method (GET, POST, etc.) over the last hour, sorted by duration. Which Kusto query should you use?
⚠ Common exam trap
The trap here is that candidates often forget to apply the time filter (`where timestamp > ago(1h)`) or mistakenly sort by the method name instead of the computed average duration, because the question explicitly says 'sorted by duration' but the options include plausible but incorrect sort columns.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
requests | where timestamp > ago(1h) | summarize avg(duration) by method | order by avg_duration desc
It first filters requests to only those from the last hour using `where timestamp > ago(1h)`, then calculates the average duration grouped by HTTP method with `summarize avg(duration) by method`, and finally orders the results by the computed average duration in descending order using `order by avg_duration desc`. This matches the requirement exactly: last hour, average duration per method, sorted by duration.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
requests | summarize avg(duration) by method | order by avg_duration desc
Why it's wrong here
This Kusto Query Language (KQL) statement correctly calculates the average duration per request method and orders them descending by that average. However, it critically lacks a time filter, meaning it will aggregate data across the entire Application Insights retention period, potentially weeks or months, instead of focusing on recent performance trends for active monitoring.
- ✗
requests | summarize avg(duration) by method | sort by method asc
Why it's wrong here
This query attempts to summarize average request durations by method but suffers from two significant flaws. Firstly, it omits any time-based filtering, causing it to process all historical data, which is inefficient and not suitable for real-time monitoring. Secondly, the `sort by method asc` clause orders the results alphabetically by the HTTP method name, which is generally not useful for identifying performance bottlenecks compared to sorting by duration.
- ✓
requests | where timestamp > ago(1h) | summarize avg(duration) by method | order by avg_duration desc
Why this is correct
This KQL query is correctly structured for monitoring recent web app performance. The `where timestamp > ago(1h)` clause efficiently filters the data to only the last hour, ensuring relevance for current operational insights. It then accurately calculates the `avg(duration)` for each `method` and presents the results ordered in `descending` fashion by this average duration, highlighting the slowest request types immediately.
- ✗
requests | where timestamp > ago(1h) | summarize avg(duration) by method | sort by method
Why it's wrong here
While this KQL query correctly applies a time filter using `where timestamp > ago(1h)` to focus on recent data, its final sorting mechanism is flawed for performance analysis. The `sort by method` clause arranges the output alphabetically by the request method (e.g., GET, POST), rather than by the calculated average duration. This prevents quick identification of the methods experiencing the highest latency, making the results less actionable.
Go deeper
Related to this question
About these practice questions
Courseiva writes every AZ-204 question from scratch — 881 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-204 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-204 exam.