Skip to content

Commit

Permalink
Updated MMA Report with Resource Graph Query
Browse files Browse the repository at this point in the history
  • Loading branch information
shaikhanwar committed Oct 23, 2023
1 parent 47ce668 commit 46db7ba
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 46 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added workload/docs/Monitoring/QueryReport.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions workload/scripts/Monitoring/01_MMA_Report.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ $VMs = Get-AzVM
$WindowsVMs = $VMs | Where-Object {$_.StorageProfile.OsDisk.OsType -eq "Windows" }
foreach ($VM in $WindowsVMs) {

$ReportDetails = "" | Select VmName, ResourceGroupName
$ReportDetails = "" | Select Name, ResourceGroupName

$extension = Get-AzVMExtension -ResourceGroupName $Vm.ResourceGroupName -VMName $VM.Name
$extension = Get-AzVMExtension -ResourceGroupName $Vm.ResourceGroupName -Name $VM.Name

if ($extension.Name -contains "MicrosoftMonitoringAgent") {
#Write-Host "Microsoft Monitoring Agent is Installed on" $VM.Name "in the RG:" $VM.ResourceGroupName
$ReportDetails.VMName = $vm.Name
$ReportDetails.Name = $vm.Name
$ReportDetails.ResourceGroupName = $vm.ResourceGroupName
$report+=$ReportDetails
}
}

$report | ft -AutoSize VmName, ResourceGroupName
$report | ft -AutoSize Name, ResourceGroupName

#Change the path based on your convenience
$report | Export-CSV "c:\temp\$reportName" –NoTypeInformation
2 changes: 1 addition & 1 deletion workload/scripts/Monitoring/02_MMA_Extention_remove.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


$PathToCsv = "C:\Temp\MMA_VMs.csv"
$computers = (Import-Csv -Path $PathToCsv).vmname
$computers = (Import-Csv -Path $PathToCsv).name

foreach ($vmName in $computers) {
$vmAzure = Get-AzVM -Name $vmName
Expand Down
20 changes: 0 additions & 20 deletions workload/scripts/Monitoring/AMA_DCR.ps1

This file was deleted.

17 changes: 0 additions & 17 deletions workload/scripts/Monitoring/MMA2AMA.kql

This file was deleted.

27 changes: 23 additions & 4 deletions workload/scripts/Monitoring/readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
# Steps to migrate Log Analytics agent (also known as MMA and OMS) to Azure Monitor Agent (AMA)

# As a reference lease review [Monitoring Agent Migration WorkFlow](https://learn.microsoft.com/en-us/azure/azure-monitor/agents/azure-monitor-agent-migration-tools?tabs=portal-1)
# As a reference please review [Monitoring Agent Migration WorkFlow](https://learn.microsoft.com/en-us/azure/azure-monitor/agents/azure-monitor-agent-migration-tools?tabs=portal-1)

## The main purposes of the scripts are:
* Create a report with Azure VMs still running legacy monitoring agent (MMA)
* Based on the report remove legacy monitoring agent

## How to use it?
- Create report via PS:
- 01_MMA_Report.ps1 - is to gather current AVD hosts wich have been monitored via MMA agent and export it to csv file
- Create report via Azure Resource Graph Explorer
- Login to [Azure Portal](https://portal.azure.com/) <img src="../../docs/icons/azure.png" width="20" height="20">
- In the main search type _'Azure Resource Graph Explorer'_

* 01_MMA_Report.ps1- is to gather current AVD hosts wich have been monitored via MMA agent and export it to csv file
* Review the report to confirm the list of VMs with MMA agent
* 02_MMA_Extention_remove.ps1 that script will reference the csv report and remove MMA agent
![Azure Resource Graph Explorer 1](../../docs/Monitoring/AzureResourceGraphExplorer1.png)

- Run the query

![Azure Resource Graph Explorer Report](../../docs/Monitoring/QueryReport.png)

```console
resources
| where type == "microsoft.compute/virtualmachines"
| extend agentversion = properties.agentVersion | project name, agentversion, location, resourceGroup, subscriptionId
```

- Review the report to confirm the list of VMs with MMA agent

- 02_MMA_Extention_remove.ps1 that script will reference the csv report and remove MMA agent

0 comments on commit 46db7ba

Please sign in to comment.