Protego field desk
Instrumentation Strategy · 5-10% of exam

L18. Analyzing Telemetry: KQL Queries, Distributed Tracing & Performance Metrics

Course outlineLesson 18 of 18

Distributed tracing correlates collected telemetry across instrumented services. Use KQL to investigate failures and test performance hypotheses without assuming correlation proves a cause.

Quick answer: For AZ-400 telemetry analysis, compare request volume with response time and failures over the same window, then use distributed tracing in Application Insights, where every request and dependency in one transaction shares an operation ID (the W3C trace ID), to find the slow hop. KQL pipes tables such as AppRequests through where, summarize and render to prove or reject the hypothesis.

Infrastructure Performance Indicators: Your Diagnostic Baseline

When an application slows down, the first question is: "Is this an application code problem or an infrastructure constraint?" Start by monitoring these infrastructure signals:

SignalWhat It MeasuresInvestigate
CPU UtilizationPercentage of processor time consumedCompute demand, expensive work and thread behavior
Memory UsageRAM consumed relative to available capacityMemory pressure, leaks, caching and available capacity
Disk I/O and LatencyRead/write speed and access time to storageStorage response time, I/O queues and dependency delays
Network ThroughputBandwidth consumed relative to available capacityLink capacity, packet loss and transfer patterns
Use these metrics to form hypotheses. Low host utilization can coexist with dependency delays, lock contention, throttling or network problems. A saturated metric is evidence to investigate, not proof of the root cause.

Correlating Usage Against Performance

A critical diagnostic pattern is correlating usage (request volume) against performance (response time and error rate) over the same time period. If response time degrades while request volume stays flat, investigate request complexity, dependencies, contention and resource limits; flat request counts do not prove load is unchanged. If response time and request volume both spike together, investigate capacity, scaling and dependency behavior under load; correlation alone does not prove the application is performing as designed.

Compare metrics over the same time window, then use traces and dependency evidence to test the suspected cause.

Distributed Tracing: End-to-End Operation Visibility

In microservices architectures, a single user request touches multiple services. A front-end calls an API, which calls a database, which queries another service. If the overall operation is slow, which hop is responsible? Distributed tracing in Application Insights answers this by correlating collected telemetry using an operation ID and parent-child relationships. Application Insights follows the W3C Trace Context standard: the operation ID is the W3C trace ID, and each request or dependency ID is a span ID, so services instrumented with OpenTelemetry and the Azure Monitor OpenTelemetry Distro show up in one end-to-end transaction view. Instrument the participating services and propagate trace context across boundaries. Sampling, unsupported dependencies or missing instrumentation can leave gaps in the transaction view; use the available spans to investigate delays and failures.

Kusto Query Language (KQL) Fundamentals

At production scale, telemetry volume can make manual inspection impractical. Instead, use KQL queries to aggregate, filter and correlate telemetry into a focused result set.

KQL is a pipe-based language. The pipe operator (|) chains operations:

requests
| where timestamp > ago(1h)
| where success == false
| summarize count() by resultCode

This query filters requests from the last hour, then to failed requests only, then groups and counts by result code.

Essential KQL Operators

Practice reading and writing queries that answer diagnostic questions. Useful operators include:

  • where: Filter rows (like SQL WHERE)
  • summarize: Aggregate (count, sum, avg, max, min)
  • project: Select specific columns
  • order by: Sort results (ascending or descending)
  • join: Combine data from two tables on a shared key
Schema matters: The example uses the Application Insights resource schema (requests, timestamp, success, resultCode). In a Log Analytics workspace, use AppRequests, TimeGenerated, Success and ResultCode:

AppRequests
| where TimeGenerated > ago(1h)
| where Success == false
| summarize FailedRequests = count() by ResultCode

Percentiles, Not Averages

Averages hide the slow tail that users complain about. To test "the checkout API got slower after Tuesday's release", chart the 95th percentile duration next to request volume:

AppRequests
| where TimeGenerated > ago(7d) and Name has "checkout"
| summarize p95_ms = percentile(DurationMs, 95), requests = count() by bin(TimeGenerated, 1h)
| render timechart

If p95 jumps at the release time while requests stay flat, open a slow operation from that window in the transaction view and check which dependency took the time. Then filter all telemetry for that transaction with its OperationId. Related: set up the data sources these queries read in lesson 17, configuring DevOps monitoring. The same KQL skills carry over to security work in threat hunting with Microsoft Sentinel and KQL.

Frequently Asked Questions

What is an operation ID in Application Insights?

It is the identifier shared by every request, dependency, trace and exception in one end-to-end transaction. It equals the W3C trace ID, which is how Application Insights stitches calls across services into one view.

What is the difference between the requests and AppRequests tables?

They hold the same request telemetry with different schemas. requests, with columns like timestamp and success, is what you query from the Application Insights resource; AppRequests, with TimeGenerated and Success, is the table in a workspace-based Log Analytics workspace.

Why use percentiles instead of average response time?

A few very slow requests barely move the average, but they are exactly what users notice. The 95th or 99th percentile shows the slow tail, so a regression after a release stands out.

Does high CPU prove the root cause of a slowdown?

No. A saturated metric is evidence to investigate, not proof. Confirm the cause with traces and dependency timings from the same time window before you scale out or roll back.

References

Continue Learning

Exam Focus Points
  • ✓CPU, memory, disk, and network are the baseline infrastructure performance indicators used to determine whether an infrastructure constraint, rather than application code, is causing a performance problem
  • ✓Distributed tracing in Application Insights correlates all telemetry for one logical operation across multiple services using an operation ID, producing an end-to-end transaction view that isolated per-service logs cannot show on their own
  • ✓Correlating usage (request volume) against performance (response time, error rate) helps investigate whether degradation correlates with load; it does not establish root cause alone
  • ✓KQL is a pipe-based query language for interrogating Log Analytics/Application Insights data, using operators like where to filter, summarize to aggregate, project to select columns, and order by to sort results
  • ✓KQL exists because manually scanning raw logs is impractical at production telemetry volume; a KQL query lets an engineer aggregate and filter across millions of rows into a focused, actionable result set
Knowledge Check

1. A single user request touches a web front end, an API, and a downstream database call, and the request is slow overall. With the services instrumented and trace context propagated, which Application Insights capability helps locate delays across those hops?

2. Which basic KQL query would correctly count failed requests by result code over the last hour, given a table called requests with a success and resultCode column?

3. An application's response time has degraded, and the team wants to know whether this is simply due to a spike in request volume or a genuine performance regression independent of load. Which metrics should they correlate as an initial diagnostic step?