Я не эксперт по OMS, но это то, что мы использовали:
{
"apiVersion": "2017-03-15-preview",
"name": "[concat(variables('namespace'), '/', variables('savedSearches').Search[copyIndex()].Name)]",
"type": "Microsoft.OperationalInsights/workspaces/savedSearches",
"copy": {
"name": "SavedSearchCopy",
"count": "[length(variables('savedSearches').Search)]"
},
"dependsOn": [
"[concat('Microsoft.OperationalInsights/workspaces/', variables('namespace'))]",
"ActionGroupCopy"
],
"properties": {
"category": "Alerts",
"displayName": "[variables('savedSearches').Search[copyIndex()].DisplayName]",
"query": "[variables('savedSearches').Search[copyIndex()].Query]"
}
},
{
"name": "[tolower(concat(variables('namespace'), '/', variables('savedSearches').Search[copyIndex()].Name, '/', variables('savedSearches').Search[copyIndex()].Schedule.Name))]",
"type": "Microsoft.OperationalInsights/workspaces/savedSearches/schedules/",
"apiVersion": "2017-03-03-preview",
"copy": {
"name": "ScheduleCopy",
"count": "[length(variables('savedSearches').Search)]"
},
"dependsOn": [
"SavedSearchCopy"
],
"properties": {
"interval": "5",
"queryTimeSpan": "10",
"enabled": true
}
},
{
"name": "[tolower(concat(variables('namespace'), '/', variables('savedSearches').Search[copyIndex()].Name, '/', variables('savedSearches').Search[copyIndex()].Schedule.Name, '/', variables('savedSearches').Search[copyIndex()].Alert.Name, '-', if(contains(variables('savedSearches').Search[copyIndex()].Alert, 'MetricsTrigger'), 'Total', 'Consecutive')))]",
"type": "Microsoft.OperationalInsights/workspaces/savedSearches/schedules/actions",
"copy": {
"name": "ActionCopy",
"count": "[length(variables('savedSearches').Search)]"
},
"apiVersion": "2017-03-15-preview",
"dependsOn": [
"SavedSearchCopy"
],
"properties": {
"Type": "Alert",
"Name": "[variables('savedSearches').Search[copyIndex()].Alert.Name]",
"Description": "[variables('savedSearches').Search[copyIndex()].Alert.Description]",
"Severity": "warning",
"Threshold": "[variables('savedSearches').Search[copyIndex()].Alert.Threshold]",
"Throttling": {
"DurationInMinutes": 60
},
"AzNsNotification": {
"GroupIds": [
"[resourceId('microsoft.insights/actionGroups', 'xxx')]"
]
}
}
},
{
"type": "Microsoft.Insights/actionGroups",
"apiVersion": "2018-03-01",
"name": "[variables('actionGroups')[copyIndex()].Name]",
"copy": {
"name": "ActionGroupCopy",
"count": "[length(variables('actionGroups'))]"
},
"location": "Global",
"properties": {
"groupShortName": "[variables('actionGroups')[copyIndex()].Name]",
"enabled": true,
"emailReceivers": [
{
"name": "[variables('actionGroups')[copyIndex()].EmailName]",
"emailAddress": "[variables('actionGroups')[copyIndex()].EmailAddress]"
}
]
}
},
вот пример сохраненной поисковой переменной, которую мы используем для отображения всего:
"savedSearches": {
"Search": [
{
"Name": "HighCPU",
"DisplayName": "CPU Above 90%",
"Query": "Perf | where CounterName == \"% Processor Time\" and InstanceName ==\"_Total\" | summarize AggregatedValue = avg(CounterValue) by Computer, bin(TimeGenerated, 1m)",
"Schedule": {
"Name": "HighCPUSchedule"
},
"Alert": {
"Name": "HighCPUAlert",
"Description": "Alert for High CPU",
"Threshold": {
"Operator": "gt",
"Value": 90,
"MetricsTrigger": {
"Value": 2,
"Operator": "gt",
"TriggerCondition": "Consecutive"
}
}
}
},
...
]
}