What is Activity Log in Azure?
Azure Activity Log is a monitoring service that records management operations performed on Azure resources.
It helps administrators identify who performed an action, what action was performed, when it happened, and whether it succeeded or failed.
Activity Logs are automatically collected by Azure at the subscription level.
1. Simple Example
Suppose you have an Azure Virtual Machine.
10:00 AM - VM Created - Succeeded
10:15 AM - VM Started - Succeeded
11:00 AM - VM Resized - Succeeded
12:00 PM - VM Deleted - Succeeded
Azure Activity Log helps you investigate these operations.
2. What Does Activity Log Record?
|
Activity |
Example |
|---|---|
|
Resource Creation |
New Virtual Machine created |
|
Resource Modification |
VM size changed |
|
Resource Deletion |
Storage Account deleted |
|
Resource Operations |
VM started or stopped |
|
Role Assignments |
User assigned Contributor role |
|
Deployment Operations |
ARM deployment succeeded or failed |
|
Policy Events |
Azure Policy denied an operation |
|
Service Health |
Azure service incident reported |
Important: Activity Logs primarily record management-plane operations, not application-level events such as user logins to your website or SQL queries.
3. How Activity Log Works
Azure Subscription
|
v
Management Operations
|
+--------+--------+
| | |
v v v
Create Update Delete
| | |
+--------+--------+
|
v
Azure Activity Log
|
+--------+--------+
| | |
v v v
Monitor Audit Alerts
4. How to View Activity Logs in Azure Portal
-
Sign in to Azure Portal.
-
Search for Monitor.
-
Select Activity log.
-
Choose your Azure subscription.
-
Select the required time range.
-
Apply filters such as:
-
Event severity
-
Resource group
-
Resource
-
Operation name
-
Event initiated by
-
-
Select an event to view its details.
You can also open a specific Azure resource and select Activity log to view relevant operations.
5. Important Activity Log Fields
|
Field |
Description |
|---|---|
|
Event Timestamp |
When the operation occurred |
|
Operation Name |
What action was performed |
|
Event Initiated By |
User or service principal that initiated the operation |
|
Status |
Succeeded, Failed, Started, etc. |
|
Resource |
Azure resource involved |
|
Resource Group |
Resource group containing the resource |
|
Correlation ID |
Identifier used to correlate related operations |
6. Activity Log vs Resource Log
|
Activity Log |
Resource Log |
|---|---|
|
Records management operations |
Records resource-specific operations |
|
Subscription-level |
Resource-level |
|
Automatically collected |
Usually requires Diagnostic Settings |
|
Example: VM deleted |
Example: Azure Firewall denied traffic |
|
Useful for auditing changes |
Useful for troubleshooting resource behavior |
7. Activity Log Retention
Azure Activity Logs are retained for 90 days by default, at no additional charge for their standard collection and retention.
For longer retention, configure Diagnostic Settings to export Activity Logs to:
-
Log Analytics Workspace — Query and analyze logs using KQL.
-
Azure Storage Account — Store logs for long-term retention.
-
Azure Event Hubs — Stream events to external monitoring systems.
Additional storage, ingestion, or streaming charges may apply.
8. Query Activity Logs Using KQL
If Activity Logs are exported to a Log Analytics workspace, you can query them.
Example: Retrieve the latest 10 activities.
AzureActivity
| order by TimeGenerated desc
| take 10
Example: Find failed operations.
AzureActivity
| where ActivityStatusValue == "Failure"
| project TimeGenerated,
OperationNameValue,
Caller,
ResourceGroup,
ActivityStatusValue
| order by TimeGenerated desc
9. Interview Quick Revision
Q: What is Azure Activity Log?
Azure Activity Log is a subscription-level log that records management operations performed on Azure resources, including creation, modification, deletion, and administrative activities.
Key Points:
-
Automatically collected by Azure.
-
Records management-plane operations.
-
Helps identify who performed an action and when.
-
Retained for 90 days by default.
-
Can be exported using Diagnostic Settings.
-
Supports monitoring, auditing, troubleshooting, and alerting.
Easy way to remember:
-
Metric: CPU usage reached 90%.
-
Resource Log: Azure Firewall denied a connection.
-
Activity Log: An administrator modified the firewall configuration.
-
Trace: An API request failed while connecting to a dependency.
Activity Log answers: Who changed what in my Azure environment, and when?
What is Log Analytics Workspace in Azure?
A Log Analytics Workspace is a centralized location in Azure Monitor used to collect, store, query, and analyze log data from Azure resources, applications, and virtual machines.
It allows administrators and developers to investigate errors, monitor resource activities, and troubleshoot application issues using Kusto Query Language (KQL).
1. Simple Example
Suppose you have the following Azure resources:
-
Azure Virtual Machine
-
Azure App Service
-
Azure SQL Database
-
Azure Storage Account
Instead of checking logs individually, you can send supported logs from these resources to a single Log Analytics Workspace.
Azure Virtual Machine
|
Azure App Service
|
Azure SQL Database
|
Azure Storage Account
|
v
Diagnostic Settings /
Monitoring Agents
|
v
Log Analytics Workspace
|
v
Query Using KQL
|
+-------+-------+
| |
v v
Troubleshooting Monitoring
| |
v v
Find Errors Alerts
Example: If your App Service fails to connect to Azure SQL Database, you can query the collected application and database logs to investigate the issue.
2. What Does Log Analytics Workspace Store?
A workspace organizes log records into tables.
|
Table |
Description |
|---|---|
|
AzureActivity |
Azure subscription management operations |
|
AppRequests |
Application HTTP requests |
|
AppExceptions |
Application exceptions |
|
AppTraces |
Application trace messages |
|
AppDependencies |
Application dependency calls |
|
Perf |
Performance counter data |
|
Heartbeat |
Monitoring agent heartbeat records |
|
AzureDiagnostics |
Resource logs using the Azure diagnostics table format |
Important: Tables contain data only when the relevant collection or export has been configured. Some Azure services use resource-specific tables instead of AzureDiagnostics.
3. How to Create a Log Analytics Workspace in Azure Portal
Step 1: Open Azure Portal
-
Sign in to Azure Portal.
-
Search for Log Analytics workspaces.
-
Click Create.
Step 2: Configure Workspace
|
Setting |
Example |
|---|---|
|
Subscription |
Your Azure subscription |
|
Resource Group |
rg-monitoring-demo |
|
Name |
law-monitoring-demo |
|
Region |
Central India |
Click Review + Create → Create.
Step 3: Open Workspace
After deployment:
-
Open the newly created workspace.
-
Select Logs.
-
You can now execute KQL queries against data collected in the workspace.
Creating a workspace does not automatically configure every Azure resource to send logs to it.
4. How to Connect Azure App Service to Log Analytics Workspace
-
Open Azure Portal → App Services.
-
Select your App Service.
-
Under Monitoring, select Diagnostic settings.
-
Click Add diagnostic setting.
-
Enter a name, such as
appservice-logs. -
Select the required log categories, such as:
-
AppServiceHTTPLogs
-
AppServiceConsoleLogs
-
AppServiceAppLogs
-
-
Enable Send to Log Analytics workspace.
-
Select your subscription and workspace.
-
Click Save.
Your App Service will begin sending the selected logs to the workspace as they are generated, subject to supported logging configuration.
5. Query Logs Using KQL
KQL stands for Kusto Query Language.
It is used to search, filter, summarize, and analyze log data.
Example 1: Get the latest 10 application requests
AppRequests
| order by TimeGenerated desc
| take 10
Example 2: Find failed application requests
AppRequests
| where Success == false
| project TimeGenerated,
Name,
ResultCode,
DurationMs
| order by TimeGenerated desc
Example 3: Find application exceptions
AppExceptions
| order by TimeGenerated desc
| take 10
These App* tables are typically populated through workspace-based Application Insights, not merely by enabling App Service diagnostic settings.
6. Log Analytics Workspace vs Application Insights
|
Log Analytics Workspace |
Application Insights |
|---|---|
|
Centralized log storage and analysis |
Application Performance Monitoring (APM) |
|
Collects logs from multiple Azure resources |
Monitors application behavior and performance |
|
Uses KQL for log analysis |
Provides request, dependency, and exception monitoring |
|
Supports infrastructure and application logs |
Supports distributed tracing |
|
Stores telemetry for workspace-based Application Insights |
Uses a workspace to store its log telemetry |
7. Log Analytics Workspace vs Azure Monitor
|
Azure Monitor |
Log Analytics Workspace |
|---|---|
|
Overall Azure monitoring platform |
Log data storage and analysis resource |
|
Handles metrics, logs, alerts, and more |
Primarily stores and queries logs |
|
Provides Metrics Explorer |
Provides access to workspace log tables |
|
Supports multiple monitoring data sources |
Organizes collected logs into tables |
8. Is Log Analytics Workspace Free?
Creating a Log Analytics Workspace does not normally incur a charge by itself.
Charges can apply for:
-
Log data ingestion
-
Log retention beyond included periods
-
Certain query or data processing features
-
Additional monitoring services
Pricing depends on the workspace configuration, table plan, and data volume.
9. Interview Quick Revision
Q1. What is Log Analytics Workspace in Azure?
A Log Analytics Workspace is a centralized Azure Monitor resource used to collect, store, and analyze logs from Azure resources and applications using KQL.
Q2. What is KQL?
Kusto Query Language is a query language used to retrieve, filter, aggregate, and analyze data stored in Azure Monitor Logs.
Q3. Can multiple Azure resources use the same workspace?
Yes. Multiple Azure resources can send their logs to the same Log Analytics Workspace, subject to supported configurations and access permissions.
Q4. Is Log Analytics Workspace mandatory for Azure Monitor?
No. Azure Monitor platform metrics and the default Activity Log can be used without a Log Analytics Workspace. However, a workspace is required for storing and querying Azure Monitor Logs.
Q5. What is the difference between Log Analytics and Application Insights?
Log Analytics is used to query and analyze log data, while Application Insights focuses on application performance, failures, requests, dependencies, and distributed tracing.
Easy Way to Remember
-
Azure Monitor: Monitors Azure resources.
-
Metrics: Measures performance.
-
Activity Log: Records Azure management operations.
-
Diagnostic Settings: Routes supported logs to destinations.
-
Log Analytics Workspace: Stores and organizes collected logs.
-
KQL: Queries and analyzes logs.
-
Application Insights: Monitors application performance and failures.
Real-time example: Your ASP.NET Core Web API returns HTTP 500 errors. Application Insights captures failed requests and exceptions, stores the telemetry in its connected Log Analytics Workspace, and allows you to investigate the failures using KQL.
Azure Practical Lab: Send Metrics and Activity Logs to Log Analytics Workspace
In this exercise, we'll configure Azure Monitor Diagnostic Settings to send Azure App Service metrics and Azure subscription Activity Logs to a Log Analytics Workspace.
We will also verify the collected data using Kusto Query Language (KQL).
1. Understand the Architecture
Azure Subscription
|
+----------+----------+
| |
v v
Azure App Service Azure Activity Log
| |
v |
Platform Metrics |
| |
v v
Diagnostic Settings
| |
+----------+----------+
|
v
Log Analytics Workspace
|
v
KQL Queries
|
+------+------+
| |
v v
Analysis Alerts
Important: Metrics and Activity Logs are different data sources. Their Diagnostic Settings are configured separately.
2. Create a Log Analytics Workspace
Step 1: Sign in to Azure Portal.
Step 2: Search for Log Analytics workspaces.
Step 3: Click Create.
Step 4: Enter the following details:
|
Setting |
Example |
|---|---|
|
Subscription |
Your Azure subscription |
|
Resource Group |
rg-monitoring-demo |
|
Workspace Name |
law-monitoring-demo |
|
Region |
Central India |
Step 5: Click Review + Create → Create.
Step 6: Once deployment completes, click Go to resource.
Your workspace is ready to receive data.
3. Send Azure Activity Logs to Log Analytics Workspace
Activity Logs are collected automatically at the subscription level, but you must configure their export to the workspace.
Step 1: In Azure Portal, search for Monitor.
Step 2: Select Activity log.
Step 3: Choose your subscription.
Step 4: Click Export Activity Logs (or Diagnostic settings, depending on the portal view).
Step 5: Click Add diagnostic setting.
Step 6: Enter the following:
|
Setting |
Value |
|---|---|
|
Diagnostic setting name |
activitylogs-to-law |
|
Destination |
Send to Log Analytics workspace |
|
Subscription |
Your subscription |
|
Workspace |
law-monitoring-demo |
Step 7: Select the log categories you want to export.
For a practical exercise, select:
-
Administrative
-
Security
-
ServiceHealth
-
Alert
-
Recommendation
-
Policy
-
Autoscale
-
ResourceHealth
Step 8: Click Save.
Activity Logs generated after the configuration is saved will be sent to the workspace. Export is not a historical backfill.
4. Verify Activity Logs Using KQL
Open your Log Analytics Workspace and select Logs.
Execute:
AzureActivity
| order by TimeGenerated desc
| take 10
To see resource modification operations:
AzureActivity
| where OperationNameValue contains "write"
| project TimeGenerated,
OperationNameValue,
Caller,
ResourceGroup,
ActivityStatusValue
| order by TimeGenerated desc
If the table is empty, perform a safe management operation, such as updating a test resource's tag, and allow time for ingestion.
5. Send Azure App Service Metrics to Log Analytics Workspace
Now configure metric export separately from Activity Logs.
Step 1: Search for App Services in Azure Portal.
Step 2: Select your App Service.
Step 3: Under Monitoring, select Diagnostic settings.
Step 4: Click Add diagnostic setting.
Step 5: Configure:
|
Setting |
Value |
|---|---|
|
Diagnostic setting name |
appservice-metrics-to-law |
|
Category type |
Metrics |
|
Metric category |
AllMetrics |
|
Destination |
Send to Log Analytics workspace |
|
Workspace |
law-monitoring-demo |
Step 6: Click Save.
If the AllMetrics category is available, Azure exports supported platform metrics to the workspace. Not every metric is exportable through Diagnostic Settings.
6. Verify Exported Metrics Using KQL
Open Log Analytics Workspace → Logs.
Execute:
AzureMetrics
| order by TimeGenerated desc
| take 10
To display average metric values over five-minute intervals:
AzureMetrics
| where TimeGenerated > ago(1h)
| summarize AvgValue = avg(Average)
by MetricName, bin(TimeGenerated, 5m)
| order by TimeGenerated desc
To identify which metrics are arriving:
AzureMetrics
| summarize Records = count() by MetricName
| order by Records desc
7. Alternative: Export Metrics Using Data Collection Rules (DCR)
Azure Monitor also supports platform metrics export using Data Collection Rules for supported resource types.
This approach offers advantages over Diagnostic Settings, including exporting selected metrics while preserving dimensions.
To configure it:
-
Open Azure Monitor.
-
Navigate to Data Collection Rules.
-
Create a rule for platform telemetry/metrics export, using the available portal workflow.
-
Select supported Azure resources.
-
Choose the metrics to export.
-
Configure the destination as your Log Analytics Workspace.
-
Create the rule.
DCR-exported metrics are stored in the AzureMetricsV2 table rather than AzureMetrics.
Verify using:
AzureMetricsV2
| take 10
Important: DCR-based platform metric export has resource and regional support requirements. Check whether your App Service resource is supported before choosing this method. Avoid enabling both export methods for the same metrics because that can create duplicate data.
8. Verify Both Data Sources
After configuring both exports, your workspace should contain the following tables once data arrives.
|
Source |
Export Method |
KQL Table |
|---|---|---|
|
Azure Activity Log |
Subscription Diagnostic Settings |
|
|
App Service Metrics |
Resource Diagnostic Settings |
|
|
Supported platform metrics |
Platform telemetry DCR |
|
You can check the volume of data arriving in the last 24 hours:
union isfuzzy=true
(AzureActivity | summarize Count=count() | extend Source="Activity"),
(AzureMetrics | summarize Count=count() | extend Source="Metrics"),
(AzureMetricsV2 | summarize Count=count() | extend Source="MetricsV2")
| project Source, Count
If a table has not been created yet, queries against it may fail or return partial results. You can first run each table query separately.
9. Common Issues and Troubleshooting
|
Issue |
Possible Cause / Solution |
|---|---|
|
|
Check subscription-level Diagnostic Settings and generate a new management operation |
|
|
Verify AllMetrics is enabled and the metric supports export |
|
No logs immediately |
Allow time for data ingestion; Activity Log export can take around 30 minutes to begin |
|
Missing metric dimensions |
Diagnostic Settings flatten multidimensional metrics; use DCR export where supported |
|
Unexpected costs |
Review ingestion volume and workspace retention settings |
10. Final Verification Checklist
Practical Lab Completion
0 / 6
Interview Quick Revision
Q: How do you send Azure Metrics and Activity Logs to a Log Analytics Workspace?
Azure Monitor Diagnostic Settings can export supported platform metrics and subscription Activity Logs to a Log Analytics Workspace. Activity Logs are configured at the subscription level, while metrics are configured at the resource level.
Key Points:
-
Activity Logs are stored in
AzureActivity. -
Metrics exported through Diagnostic Settings are stored in
AzureMetrics. -
Metrics exported through platform telemetry DCRs are stored in
AzureMetricsV2. -
KQL is used to query and analyze the collected data.
-
Data ingestion and retention may incur charges.
Microsoft documentation: Azure Monitor Diagnostic Settings and Metrics export using DCRs.