0
votes

I have deployed a multi-resource metric (new) alerts for CPU monitoring for all my VMs. currently i have two open Monitor alerts in my subscription (Status: Fired).

alerts fired in portal

Problem is, that when i try to retrive the the opend alerts from my PC via Azure AZ Module, i keep getting the same message, but without any output (although i can see the alerts in the portal):

WARNING: 5:01:06 PM - *** The namespace for all the model classes will change from
Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.
WARNING: 5:01:06 PM - *** The namespace for output classes will be uniform for all classes in future releases to make
it independent of modifications in the model classes.
WARNING: [Get-AzAlertHistory] Parameter deprecation: The DetailedOutput parameter will be deprecated in a future
breaking change release.

I couldn't retrieve the alerts history using any of the Get-AzAlertHistory cmdlets:

PS C:\Users\Administrator> Get-AzAlertHistory
WARNING: 5:15:08 PM - *** The namespace for all the model classes will change from
Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.
WARNING: 5:15:08 PM - *** The namespace for output classes will be uniform for all classes in future releases to make
it independent of modifications in the model classes.
WARNING: [Get-AzAlertHistory] Parameter deprecation: The DetailedOutput parameter will be deprecated in a future
breaking change release.
PS C:\Users\Administrator> Get-AzAlertHistory -Caller Microsoft.Insights/alertRules
WARNING: 5:15:38 PM - *** The namespace for all the model classes will change from
Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.
WARNING: 5:15:38 PM - *** The namespace for output classes will be uniform for all classes in future releases to make
it independent of modifications in the model classes.
WARNING: [Get-AzAlertHistory] Parameter deprecation: The DetailedOutput parameter will be deprecated in a future
breaking change release.
PS C:\Users\Administrator> Get-AzAlertHistory -Status Fired
WARNING: 5:16:04 PM - *** The namespace for all the model classes will change from
Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.
WARNING: 5:16:04 PM - *** The namespace for output classes will be uniform for all classes in future releases to make
it independent of modifications in the model classes.
WARNING: [Get-AzAlertHistory] Parameter deprecation: The DetailedOutput parameter will be deprecated in a future
breaking change release. 

Could it be that there is a problem with the current az.monitor module?

1
Can you try those AZ PS cmdlets in the Azure Portal cloud shell and let me know the statusSumanthMarigowda-MSFT
Same output as my local PCedwio
I can repro your issue, and it can work use the following code: Get-AzAlertHistory -StartTime 2019-04-20T11:00:00 -EndTime 2019-05-23T12:00:00 -DetailedOutputIvan Yang
Strange, i don't understand why the command isn't working for me.. i've also tried your code: Get-AzAlertHistory -StartTime 2019-04-20T11:00:00 -EndTime 2019-05-20T12:00:00 -DetailedOutput but i go the same outputedwio
Try to use a later date for EndTime? like 2019-05-21T12:00:00?Ivan Yang

1 Answers

0
votes

Try the new cmdlet Get-AzAlert which needs the module Install-Module -Name Az.AlertsManagement

For example: To get the alert datetime and monitor condition,

Get-AzAlert -TargetResourceId <resourceID> -Select "StartDateTime,MonitorCondition"

Reference https://docs.microsoft.com/en-us/powershell/module/az.alertsmanagement/get-azalert?view=azps-6.3.0