How to create Azure Monitor Alerts based on policy definitions?
-
First of all, you need to have Log Analytics Workspace with logs from Activity log:
More info: https://docs.microsoft.com/en-us/azure/azure-monitor/platform/activity-log-collect
- Please go to Monitor.
- Go to Tab Alerts (You can go to directly to this link: https://portal.azure.com/#blade/Microsoft_Azure_Monitoring/AzureMonitoringBrowseBlade/alertsV2)
- Press New alert rule
- Press Resource
-
Select subscription and Log Analytics that have like here:
-
To use custom queries, you should be able to see here something like this:
-
Choose:
- Select
- Type a query e.g.: AzureActivity| where TimeGenerated > ago(60d) and OperationNameValue starts with “Microsoft.Authorization/roleDefinitions/write”
- Configure e.g. Number of results greater than 0. Period and Frequency.
- Create action groups – who should receive alerts.
- Specify Subject line and Alert rule name
- Save Alert
References 1: https://docs.microsoft.com/en-us/azure/azure-monitor/platform/activity-log-collect
References 2: https://docs.microsoft.com/en-us/azure/azure-monitor/platform/alerts-log