liveBook · Manning

Log Analytics

As explained in Microsoft Azure in Action

A Log Analytics workspace is an Azure data repository and management boundary in which log and telemetry data is collected, stored, and queried.

A metric can tell you a virtual machine is struggling; a log can help explain why. Log Analytics brings VM logs and telemetry into a workspace, where you can search across them with Kusto Query Language (KQL). Instead of opening one machine at a time, you can investigate what happened across your environment. section 3.6.2 section 3.7.1

The clues come from different places:

  • Activity logs record Azure control-plane actions, such as starting a VM or changing its configuration. Use them to check who did what and when. section 3.7
  • Diagnostic and guest logs expose what is happening inside the VM. Depending on what you collect, these include performance counters, application logs, Windows Event Logs, and Linux syslog. section 3.6.2 section 3.7
  • Heartbeat signals report whether a VM is still checking in. Missing signals are a clue worth investigating, not an explanation on their own. section 3.6.2 section 3.7.1

First, enable VM diagnostics and send the logs you need to a Log Analytics workspace. In the Azure Portal, open the workspace connected to your VM and select Logs to run KQL queries. You can filter by time, correlate sources, and reuse queries in workbooks—interactive dashboards combining queries, metrics, and visualizations. Once a pattern matters operationally, use it to drive an alert or dashboard. Collecting logs without acting on them is rather like saving every receipt and never checking the bill. section 3.6.2 section 3.7.1

Investigate an unexpected reboot

Suppose an application is sluggish and you suspect its VM restarted overnight. Query the Heartbeat table for each machine’s latest check-in; a gap may point to a reboot. Then look for Windows system events or Linux syslog entries around that time. Cross-check nearby updates, service failures, and Azure Activity Log operations before deciding what caused the interruption. section 3.7.1

Heartbeat
| where TimeGenerated > ago(24h)
| summarize LastSeen=max(TimeGenerated) by Computer

This KQL query finds each computer’s most recent heartbeat in the past 24 hours—the first clue in the reboot investigation. section 3.7.1

How Microsoft Azure in Action covers it

How deep it goes
Works through a VM-restart investigation with KQL queries and cross-checks, without detailing workspace provisioning or retention settings.
Examples
Traces an unexpected VM restart through heartbeat gaps, Windows Event Logs or Linux syslog, and Azure Activity Log operations.
What it assumes
Introduces Kusto Query Language through short queries while assuming access to a VM-connected workspace in the Azure Portal.
What you can do after
Diagnose/debug with it by querying heartbeat and reboot events, correlating Activity Log operations, and acting on patterns with alerts or dashboards.
How it connects
Connects Azure Monitor, virtual-machine diagnostics, Kusto Query Language, workbooks, alerts, and Azure Monitor Agent.

Also explained in

Compare how 3 books explain Log Analytics →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microsoft Azure in Action. The section links point to the parts of the book it draws on.