Skip to content

ssemyan/CreateClassicAzureVmAlerts

Repository files navigation

Create Classic Azure VM Alerts

Note: Classic Style alerts are scheduled to be depricated June 30, 2019. Read more about this here: https://docs.microsoft.com/en-us/azure/azure-monitor/platform/monitoring-classic-retirement

For an example on how to create the new-style of alerts in Azure Monitor, go here: https://github.com/ssemyan/CreateAzureMonitorVmAlerts

This PowerShell script and ARM templates will create classic-style Azure alerts that email specified addresses when:

  1. The memory usage of the VM exceeds 80% for 5 minutes
  2. The CPU usage of the VM exceeds 80% for 5 minutes
  3. The network in of the VM falls below 15K for 5 minutes

The PowerShell script will set these alerts for every VM in the specified resource groups. This requires the VM Guest Diagnostics extension to be installed. Learn more about this here:

To install the Windows VM Extension while creating the alerts, set the value of $addExtension to $TRUE and update the values for $existingdiagnosticsStorageAccountName and $existingdiagnosticsStorageResourceGroup

To only install the extension and not create alerts, set the value of $addAlerts to $FALSE

To use this script edit the details in CreateAlertsOnAllVmsInResourceGroups.ps1:

First update the list of resource groups to search:

$resourceGroupsToProcess = @('my_group', 'my_group_2')

Alternatively, if you want to run against all resource groups uncomment out this line:

#$resourceGroupsToProcess = @()

Then update the email(s) to send alerts to (comma-separated if more than one):

Finally, run the following command in PowerShell. Note: this requires the Azure PowerShell Module and if using the new version, the script will set the AzureRm alias via Enable-AzureRmAlias.

.\CreateAlertsOnAllVmsInResourceGroups.ps1

Releases

No releases published

Packages

No packages published