Log Analytics, KQL and Application Insights: Query Logs, Build Workbooks and Monitor Applications

Microsoft Certified Azure Administrator Associate AZ 103 60 min min read Updated: Nov 17, 2026 Intermediate
Log Analytics, KQL and Application Insights: Query Logs, Build Workbooks and Monitor Applications
Intermediate Topic 2 of 3

Log Analytics Workspace

bash az monitor log-analytics workspace create -g rg-ops -n law-ops --location centralindia --retention-time 90 az monitor log-analytics workspace show -g rg-ops -n law-ops --query "{id:id, customerId:customerId, retention:retentionInDays}"
  • Stores log data in tables (for example Heartbeat, Perf, AzureActivity, Syslog, Event)
  • You pay by GB ingested and retention. Choose retention per table when needed
  • Use resource-context RBAC so teams see only their resources' logs

Connect VMs

  1. Install the Azure Monitor Agent (AMA) extension on the VM
  2. Create a data collection rule (DCR) choosing what to collect (performance counters, Windows events, Syslog)
  3. Associate the DCR with the VMs
  4. Turn on VM insights for maps and performance charts

AMA replaces the older Log Analytics (MMA/OMS) agent. Check the current guidance when you see older documents.

KQL Basics

Each step passes rows to the next step with the pipe |.

kql // All VMs that sent a heartbeat in the last 10 minutes Heartbeat | where TimeGenerated > ago(10m) | summarize last = max(TimeGenerated) by Computer // Average CPU per computer, 5-minute buckets Perf | where ObjectName == "Processor" and CounterName == "% Processor Time" | where TimeGenerated > ago(1h) | summarize avgCpu = avg(CounterValue) by Computer, bin(TimeGenerated, 5m) | render timechart // Who deleted resources in the last 7 days AzureActivity | where TimeGenerated > ago(7d) and OperationNameValue endswith "DELETE" and ActivityStatusValue == "Success" | project TimeGenerated, Caller, Resource, ResourceGroup
OperatorUse
whereFilter rows
projectChoose columns
extendAdd computed columns
summarize ... byGroup and calculate (count, avg, max, dcount)
order by / topSort and limit
join / unionCombine tables
renderDraw a chart
ago(), bin()Time helpers

Save and Use Queries

  • Save queries and share in query packs
  • Pin results to dashboards or build workbooks that mix text, queries and charts
  • Create a log search alert from a query (for example more than 5 errors in 5 minutes)

Application Insights

  • Application performance monitoring for web apps and APIs: requests, dependencies, exceptions, response times, users
  • Create it workspace-based (data lands in Log Analytics)
  • Enable for App Service with one click or add the OpenTelemetry-based Azure Monitor SDK for your language
  • Features: Application map, Live metrics, Availability tests (ping tests from many locations), Failures and Performance views
kql requests | where timestamp > ago(1h) | summarize total = count(), failed = countif(success == false), p95 = percentile(duration, 95) by name | order by failed desc

Practice

  1. Create a workspace and connect a VM with AMA
  2. Run a query for CPU per computer and render a chart
  3. Create a log alert for repeated failures
  4. Add an availability test for a web app

Conclusion

Log Analytics stores logs you query with KQL. Use AMA and data collection rules to bring in VM data, workbooks to present it and Application Insights to monitor your applications.

Quick Summary: workspace; connect VMs; KQL; saving; Application Insights.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators