Skip to content
AI-200 Learn

Monitoring & KQL Troubleshooting

Observe AI workloads with OpenTelemetry, Application Insights, Log Analytics and KQL: traces, tables, queries, dashboards, workbooks and alerts.

What this covers

The observability half of the secure/monitor domain is end-to-end visibility into distributed AI apps: instrument with OpenTelemetry, export to Azure Monitor Application Insights, store in a Log Analytics workspace, and analyze with KQL, dashboards, workbooks and alerts. This guide is the one-page summary; the deep notes live in the learning path Observe and troubleshoot apps on Azure.

Exam weight: Secure, monitor, and troubleshoot Azure solutions (20–25%)

Skills measured

  • "Trace distributed systems by using OpenTelemetry SDKs"
  • "Write KQL queries to analyze logs and metrics"

Key concepts

Definitions

TermDefinition
OpenTelemetryVendor-neutral API/SDK for traces, metrics and logs
Azure MonitorAzure's observability platform (metrics, logs, alerts, workbooks)
Application InsightsAPM feature for app requests, dependencies, exceptions, traces
Log Analytics workspaceShared log store queried with KQL
KQLKusto Query Language: pipeline queries over tables
OperationIdCorrelation ID for one end-to-end request (= OTel trace ID)
Custom dimensionsDynamic properties from span attributes (customDimensions classic, Properties workspace)
WorkbookInteractive parameterized analysis report
Action groupNotification and automation targets for alert rules

Vocabulary (OTel to Azure)

OpenTelemetryApplication Insights
TraceOperation (OperationId / operation_Id)
SERVER / CONSUMER spanRequest row (AppRequests)
CLIENT / PRODUCER / INTERNAL spanDependency row (AppDependencies)
AttributesProperties / customDimensions
service.nameCloud role (AppRoleName / cloud_RoleName)
Context propagationDistributed tracing (traceparent)

Standard tables

Workspace tableClassic nameContents
AppRequestsrequestsIncoming requests
AppDependenciesdependenciesOutbound HTTP / DB / queue calls and internal spans
AppTracestracesLog messages
AppExceptionsexceptionsExceptions
AppMetricscustomMetricsCustom metrics

Classic names work when you query from the Application Insights resource; App* names when you query the workspace. Tables are pre-created; you never define them.

How it works

Diagram source: flowchart LR A[App + OTel SDK] --> B[Azure Monitor exporter] B --> C[Application Insights] C --> D[(Log Analytics tables)] D --> E[KQL / dashboards / workbooks / alerts]
Code
App (OTel SDK) → Azure Monitor exporter → Application Insights
      → Log Analytics tables → KQL / dashboards / alerts

Hands-on

Azure CLI

Create a workspace and a workspace-based Application Insights resource:

Azure CLI / Bash
az monitor log-analytics workspace create \
  --resource-group <resource-group> \
  --workspace-name <workspace-name> \
  --location eastus

az monitor app-insights component create \
  --app <app-insights-name> \
  --location eastus \
  --resource-group <resource-group> \
  --workspace <workspace-name>

Python

Quick instrumentation:

Python
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import trace

configure_azure_monitor()  # reads APPLICATIONINSIGHTS_CONNECTION_STRING
tracer = trace.get_tracer(__name__)

with tracer.start_as_current_span("generate_embedding") as span:
    span.set_attribute("gen_ai.model", "text-embedding-3-large")
    embedding = model.embed(text)

KQL

Failures and P95 per hour for embedding requests:

KQL
AppRequests
| where TimeGenerated > ago(24h)
| where Name has "embed"
| summarize
    count(),
    Failures = countif(Success == false),
    P95 = percentile(DurationMs, 95)
  by bin(TimeGenerated, 1h)
| order by TimeGenerated desc

Full trace for one operation (Type = source table):

KQL
union AppRequests, AppDependencies, AppTraces, AppExceptions
| where OperationId == "abc123def456"
| project TimeGenerated, Type, Name, Message, DurationMs
| order by TimeGenerated asc

Exam traps

NeedChoose
Instrument Python quicklyazure-monitor-opentelemetry + configure_azure_monitor()
Queue consumer joins the producer's traceextract() context + SpanKind.CONSUMER
Control ingestion costSampling (rate limited default, or fixed percentage)
Correlate rows of one requestOperationId
At-a-glance team healthAzure dashboard
Interactive investigation with parametersWorkbook
Alert on custom attribute or percentileLog search alert
Alert without a known thresholdSmart detection

Quick review

  • Distro package (azure-monitor-opentelemetry) configures exporter + auto-instrumentation in one call.
  • Spans map to AppRequests / AppDependencies; attributes to Properties / customDimensions.
  • Tables such as AppExceptions are pre-created.
  • Debug with OperationId across a union of App* tables.
  • Use countif for error rate and percentile for latency.
  • Alert on error rate, P95 latency and dependency failures via metric or log search rules.

Practice

Practice: OpenTelemetry questions · Practice: KQL questions

Related study path topics:

Official references