Create Azure monitor Alert based on Custom metrics

Azure Diagnostics Extension provides the basic monitoring and diagnostics capabilities on a Azure resources.

Diagnostics agent enable monitoring Azure guest VM, with capabilities to use standard metrics and to add a new extended metrics that are not collected by default.

This is can be done by allowing “Diagnostics Settings” on azure virtual machine, “Enable guest level monitoring”, select the ‘basic’ counters collection or ‘custom’ to configure custom metric ‘performance counter’.

For example, add new collection custom metric: free space of C drive: \LogicalDisk(C:)\% Free Space

NOTE: by deselecting listed performance counters, you can remove the default counters.

In Metrics blade see the “C drive free space” metric on a selected VM:

Create Alert Rule based on custom metrics

Alerts in Azure Monitor provide a way to get notified when one of your metrics cross a threshold, Click Select target, in the context pane that loads, select a target resource that you want to alert on. Use Subscription and Resource type drop-downs to find the resource you want to monitor. You can also use the search bar to find your resource.

If the selected resource has metrics you can create alerts on, Available signals on the bottom right will include metrics.

Once you have selected a target resource, click on Add condition.

You will see a list of signals supported for the resource, select the metric you want to create an alert on.

“WAD Metrics” not available for notification, neither on VM Target nor on Log Analytics resource, this is because the information is stored in Azure storage account and not in Log analytics.

Create Alert required to install log analytics VM extension.

Enable the Log Analytics VM Extension and add the metric/counter:

To be able to select the “Metrics” on condition section in Alert rule, there is two options, a) typing query directly in the condition, b) saving the query and select it in the condition:

  • 1. Create Alert rule on workspace source, set condition “Custom log search” type the query showing the metric result:

In this example I added the Logical disk C drive metric, query based on this metric where the free space is above the threshold in alert rule condition:

LA Query to return the metric result:


| where ObjectName == “LogicalDisk” and CounterName == “% Free Space” and InstanceName == “C:”

| summarize arg_max(TimeGenerated, *) by InstanceName

  • 2. Save the query and select the SIGNAL in the condition.
    • Save the query in Logs pane.


Running a query in Az monitor Logs on a VM scope, does not allow the query to be saved:

You must run this query from Monitor blade > Logs, and now you can click on Save!

The query is now available for use in alerts and future searches.

Create an Alert on a workspace resource, and open the condition with saved search:


One thought on “Create Azure monitor Alert based on Custom metrics

Leave a Reply