Azure Monitor Agent
What is Azure Monitor Agent?
Azure Monitor Agent (AMA) is a lightweight and efficient data collection tool used in Azure Monitor to gather telemetry data from various sources within your infrastructure. It consolidates data collection for metrics, logs, and traces into a single agent, simplifying management and improving performance. This agent replaces the older Log Analytics Agent (MMA) and the Diagnostics Extension (WAD).
Key Features of Azure Monitor Agent:
Unified Data Collection: Collects metrics, logs, and traces across different Azure and non-Azure environments.
Efficiency: Optimized for performance, reducing resource consumption on monitored machines.
Flexible Configuration: Supports multiple data collection rules (DCRs) for granular data collection.
Scalability: Scales to meet the needs of large, complex environments.
Security: Enhanced security features to ensure data integrity and confidentiality.
Setting Up Azure Monitor Agent
Prerequisites:
An Azure subscription.
Azure CLI installed.
Appropriate permissions in Azure.
Step-by-Step Setup for Windows and Linux Devices
1. Create a Data Collection Rule (DCR):
Data Collection Rules define what data to collect and where to send it.
az monitor data-collection rule create --resource-group <ResourceGroup> --name <DCRName> --location <Location>
2. Define the Data Collection Configuration:
Specify the data sources, transformation, and destinations within the DCR.
code{
"dataFlows": [
{
"streams": ["Microsoft-Perf"],
"destinations": ["<LogAnalyticsWorkspace>"]
}
],
"destinations": {
"logAnalytics": [
{
"workspaceResourceId": "<LogAnalyticsWorkspaceResourceID>"
}
]
}
}
3. Install the Azure Monitor Agent on Windows:
Option 1: Using the Azure Portal
Navigate to Azure Monitor > Settings > Agents > Azure Monitor Agent.
Click on + Add and follow the wizard to select the appropriate scope (VM or VMSS).
Complete the installation by associating the DCR.
Option 2: Using PowerShell
# Download the AMA installer
Invoke-WebRequest -Uri https://aka.ms/InstallAzureMonitorAgent -OutFile InstallAzureMonitorAgent.ps1
# Execute the installer
.\InstallAzureMonitorAgent.ps1
# Link the VM to the DCR
$vm = Get-AzVM -ResourceGroupName <ResourceGroup> -Name <VMName>
Set-AzVMExtension -ResourceGroupName <ResourceGroup> -VMName <VMName> -Name "AzureMonitorWindowsAgent" -Publisher "Microsoft.Azure.Monitor" -Type "AzureMonitorWindowsAgent" -TypeHandlerVersion "1.0" -Settings @{
"dataCollectionRuleId" = "/subscriptions/<SubscriptionID>/resourceGroups/<ResourceGroup>/providers/Microsoft.Insights/dataCollectionRules/<DCRName>"
}
4. Install the Azure Monitor Agent on Linux:
Option 1: Using the Azure Portal
Navigate to Azure Monitor > Settings > Agents > Azure Monitor Agent.
Click on + Add and follow the wizard to select the appropriate scope (VM or VMSS).
Complete the installation by associating the DCR.
Option 2: Using Azure CLI
# Download and install the AMA
wget https://aka.ms/InstallAzureMonitorAgentLinux -O InstallAzureMonitorAgentLinux.sh
chmod +x InstallAzureMonitorAgentLinux.sh
sudo ./InstallAzureMonitorAgentLinux.sh
# Link the VM to the DCR
az vm extension set \
--resource-group <ResourceGroup> \
--vm-name <VMName> \
--name AzureMonitorLinuxAgent \
--publisher Microsoft.Azure.Monitor \
--version 1.0 \
--settings '{"dataCollectionRuleId":"/subscriptions/<SubscriptionID>/resourceGroups/<ResourceGroup>/providers/Microsoft.Insights/dataCollectionRules/<DCRName>"}'
Monitoring and Managing Azure Monitor Agent
Verification: Ensure the agent is running and data is being collected correctly.
Check the status of the agent service.
Verify data in the Log Analytics Workspace.
Updating AMA: Azure Monitor Agent updates are managed automatically through Azure Update Management. You can also manually update if required.
Troubleshooting:
Review logs and events related to the agent.
Check Azure Monitor diagnostic settings and review telemetry data.
Last updated