Why Log Analytics & KQL?
Metrics give you what is happening right now, but for troubleshooting, auditing, and root-cause analysis, you need deep insights from logs. That’s where Log Analytics and Kusto Query Language (KQL) come in.
They allow you to query, correlate, and visualize telemetry data from Azure resources, applications, and hybrid environments.
Log Analytics Overview
Definition:
A feature of Azure Monitor that provides a centralized workspace for storing and analyzing logs using KQL.
Sources of Logs:
-
Azure Activity Logs (who created/deleted resources).
-
Resource Logs (VM events, NSG flow logs, database queries).
-
Application Insights telemetry.
-
Security & compliance logs (via Defender for Cloud, Sentinel).
KQL (Kusto Query Language) Basics
1. Structure
-
SQL-like but optimized for log/time-series data.
-
Example:
2. Common Operators
-
where→ filter data. -
project→ select columns. -
summarize→ aggregate results. -
join→ combine logs from multiple tables. -
render→ visualize (chart, timechart, pie).
3. Example Queries
-
Find top 5 VMs with highest CPU:
-
Detect failed logins:
Best Practices
-
Use separate workspaces per environment (Dev, Prod) but centralize queries via dashboards.
-
Set retention policies → avoid unnecessary storage costs.
-
Save frequent queries as workbooks or dashboards for visualization.
-
Combine Log Analytics with Alerts → proactive notifications.
Example Enterprise Scenario
A financial services company requires:
-
Detect unusual admin logins.
-
Track VM CPU usage trends over 30 days.
-
Investigate network traffic from unknown IP ranges.
Correct design:
-
Send Entra ID sign-in logs to Log Analytics.
-
Run KQL query to detect abnormal login attempts.
-
Collect VM Perf counters to analyze CPU usage.
-
Use NSG flow logs for traffic monitoring.
Confusion Buster
-
Metrics vs KQL Logs
-
Metrics = real-time performance (numbers).
-
Logs = historical + contextual data (events).
-
-
Log Analytics vs Sentinel
-
Log Analytics = query engine.
-
Sentinel = SIEM built on top of Log Analytics.
-
-
Retention vs Export
-
Retention = keep logs in workspace.
-
Export = send logs to external SIEM or storage.
-
Exam Tips
-
“Which query language is used in Log Analytics?” → KQL.
-
“Which tool helps investigate failed login attempts?” → Log Analytics with KQL.
-
“Which service correlates NSG flow logs with traffic analysis?” → Log Analytics.
-
“Which feature stores logs for historical analysis?” → Log Analytics Workspace.
What to Expect in the Exam
-
Direct Q: “Which language is used in Azure Monitor Log Analytics?” → KQL.
-
Scenario Q: “Company wants to investigate who deleted a VM.” → Query Activity Logs in Log Analytics.
-
Scenario Q: “Company wants to visualize CPU usage trend for last month.” → KQL query with timechart.
-
Trick Q: “KQL and SQL are interchangeable.” → False.