4

I have one virtual machine . Now I want if my disk space showing very low I mean less than 2 gb. Then I want to trigger azure monitor alerts and want to get Email regarding this. is there any metrics azure monitor provide.

DnyaneshSurya
  • 187
  • 1
  • 1
  • 14
  • Not a specific answer to your question but we've found Azure Monitor painfully useless when it comes to sending alert emails. Both myself, and our Azure CSP (i.e. supposed MS-endorsed Azure experts) have been unable to find a way to include anything more useful that the ResourceID in the emailed alert. We've opted for a Free PRTG install instead which is far easier to install and configure. – Chris Butler Jul 22 '21 at 21:31

1 Answers1

4

There are no predefined alerts for diskspace as of now . But you can create a new alert with custom log search to get the details and then trigger the email to you.

Step 1 : Go to Alerts on your Monitor Page and click on New alert rule .

enter image description here

Step 2: Then select the resource and by resource here you have to select the Log analytics workspace which you have enabled the VM monitoring for . In my case its TestLog.

enter image description here

Step 3: Now select the Custom Log Search .

enter image description here

Step 4: Then provide the Custom Query which I have provided below in the search query box and you can set the threshold value to “0” and period and frequency in mins as per your requirement for an example I have set it to 60mins.

enter image description here

Step 5: Now Select an existing Action group that you have or you can create a new one by clicking on create new and filling the details . After its Created click on the action group and add the notification type as Email or anything you want to specify.

enter image description here

enter image description here

Step 6: Fill rest details like email subject and severity of the alert you want to set it to and then create alert.

enter image description here

Custom Query:

let setgbvalue = 200;//Set the disk space you want to check for. 

 Perf 

 | where TimeGenerated > ago(1h)

 | where ObjectName == "LogicalDisk" and CounterName == "Free Megabytes" 

// exclude all others as we are checking for C: here 

 | where InstanceName != "D:"  

 | where InstanceName  != "_Total" 

 | where InstanceName != "HarddiskVolume1" 

 | extend FreeSpaceGB = CounterValue/1024 // converting the counter value to GB 

 | summarize FreeSpace = min(FreeSpaceGB) by Computer, InstanceName 

 | where FreeSpace < setgbvalue //setting condition to check if the value is less than our set value . 

enter image description here

Sample :

To test it I had set the value to 200GB and my disk space was 106GB. I received the mail as below.

enter image description here enter image description here

Ansuman Bal
  • 9,705
  • 2
  • 10
  • 27