Creating Azure Virtual Machine Performance Alerts

Posted on September 8, 2017 by Aidan Finn in Microsoft Azure with

This post will show you how to use Azure virtual machine performance threshold alerts to trigger email alerts or start automated-response actions.

 

Metrics

A pre-requisite to creating alerts is that you have enabled metrics monitoring for your virtual machines. By default, we get guest-level metrics from the Azure Hyper-V hosts. However, more interesting information is available from the guest OS, such as SQL Server, memory available, and so forth. You can enable guest level monitoring in each virtual machine’s Diagnostics Settings and either stick with the default set of collected Basic metrics or customize the metrics that are gathered.

Creating Alerts

You can view metrics and create alerts in two ways:

  • Open Alert Rules in the settings of the virtual machine.
  • Select a virtual machine in Monitor > Alerts.

It would be good to get into the habit of using Azure Monitor for centralized management of virtual machines, so I will use the latter option.

I opened Monitor from the navigation bar in the Azure Portal and clicked Alerts. Each alert that you create is associated with a virtual machine, so I then selected:

  • Subscription: Pick the subscription from the tenant that contains the virtual machine.
  • Source: Choose Metrics.
  • Resource Group: Select the resource group that the virtual machine is in.
  • Resource: Choose the virtual machine that you want to create an alert for.
Sponsored

The +Add Metric Alert button was then enabled, so I clicked it. The Add Rule blade appears. This is a long blade with tons of options. I want to create an alert to respond to when processor utilization is over 80 percent for 10 minutes, so I enter the following configuration:

  • Name: Enter a unique name for the alert
  • Description: Choose a description for the alert
  • Alert on: Metrics
  • Subscription: The subscription of the virtual machine
  • Resource Group: The resource group of the virtual machine
  • Resource: The virtual machine
  • Metric: You can choose any of the metrics being collected from the virtual machine. In this case, I selected Percentage CPU, a host-level metric.

Note that the diagram below Metric is updated. A light-blue line shows the current measurements and the dark-blue line shows the threshold of the alert.

Now, I configured the threshold:

  • Condition: This is whether the alert is less than or more than the configured threshold. I have chosen Greater Than Or Equal To.
  • Threshold: Enter a numeric value. In this case, I entered 80 percent.
  • Period: You probably do not want to know about transient spikes, which can be common but have little effect on performance. I want to have an alert only if there is a performance issue over 10 minutes, so I select Over The Last 10 Minutes.
Creating a performance metric alert for an Azure virtual machine [Image Credit: Aidan Finn]

Creating a Performance Metric Alert for an Azure Virtual Machine [Image Credit: Aidan Finn]

That is the threshold part of the alert done. Now we must configure the response. The following options are available:

  • Notify: Email Owners, Contributors, And Readers: Anyone with these permissions on the virtual machine will get an email notification.
  • Additional Administrator Email(s): You can send an email to other addresses, such as a ticketing or on-premises monitoring system.
  • Webhook: You can enter the URL to a webhook to trigger an action in some external system.
  • Take Action: Execute a runbook in an Azure Automation Account and/or execute an Azure logic app.
How the alert response to a breach of the Azure virtual machine metric threshold [Image Credit: Aidan Finn]

How the Alert Response to a Breach of the Azure Virtual Machine Metric Threshold [Image Credit: Aidan Finn]

The ability to trigger Automation runbooks based on metrics being above or below a certain level creates some interesting possibilities. For example:

  • Scale up a service when CPU is in high demand.
  • Scale down a service when CPU is in low demand.
Sponsored

The alert will be saved if you click OK. You will get emails in the event of the alert being triggered but you can also view the status of this alert and all alerts in Monitor > Alerts.

Viewing the alert status in Azure Monitor [Image Credit: Aidan Finn]

Viewing the Alert Status in Azure Monitor [Image Credit: Aidan Finn]

Now, you should be able to be proactive about the quality of service that your virtual machines are providing.

Sponsored

Tagged with , , , , , , , , ,