Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Den här artikeln innehåller exempel på Azure Resource Manager-mallar för att skapa och konfigurera aviseringar för loggsökning i Azure Monitor. Varje exempel innehåller en mallfil och en parameterfil med exempelvärden som ska tillhandahållas mallen.
Anmärkning
Se Azure Resource Manager-exempel för Azure Monitor för en lista över exempel som är tillgängliga och vägledning om hur du distribuerar dem i din Azure-prenumeration.
Anmärkning
Den kombinerade storleken på alla data i loggaviseringsregelns egenskaper får inte överstiga 64 KB. Detta kan orsakas av för många dimensioner, frågan är för stor, för många åtgärdsgrupper eller en lång beskrivning. När du skapar en stor aviseringsregel bör du komma ihåg att optimera dessa områden.
Mall för alla resurstyper (från version 2025-01-01-preview)
I följande exempel skapas en regel som kan rikta sig mot valfri resurs.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Name of the alert"
}
},
"location": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Location of the alert"
}
},
"alertDescription": {
"type": "string",
"defaultValue": "This is a metric alert",
"metadata": {
"description": "Description of alert"
}
},
"alertSeverity": {
"type": "int",
"defaultValue": 3,
"allowedValues": [
0,
1,
2,
3,
4
],
"metadata": {
"description": "Severity of alert {0,1,2,3,4}"
}
},
"isEnabled": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "Specifies whether the alert is enabled"
}
},
"autoMitigate": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Specifies whether the alert will automatically resolve"
}
},
"resourceId": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Full Resource ID of the resource emitting the metric that will be used for the comparison. For example /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroups/ResourceGroupName/providers/Microsoft.compute/virtualMachines/VM_xyz"
}
},
"query": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Name of the metric used in the comparison to activate the alert."
}
},
"muteActionsDuration": {
"type": "string",
"allowedValues": [
"PT1M",
"PT5M",
"PT15M",
"PT30M",
"PT1H",
"PT6H",
"PT12H",
"P1D"
],
"metadata": {
"description": "Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired."
},
"actionGroupId": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "The ID of the action group that is triggered when the alert is activated or deactivated"
}
}
},
"resources": [
{
"type": "Microsoft.Insights/scheduledQueryRules",
"apiVersion": "2025-01-01-preview",
"kind": "SimpleLogAlert",
"name": "[parameters('alertName')]",
"location": "[parameters('location')]",
"tags": {},
"properties": {
"description": "[parameters('alertDescription')]",
"severity": "[parameters('alertSeverity')]",
"enabled": "[parameters('isEnabled')]",
"scopes": [
"[parameters('resourceId')]"
],
"criteria": {
"allOf": [
{
"query": "[parameters('query')]",
}
}
]
},
"autoMitigate": "[parameters('autoMitigate')]",
"muteActionsDuration": "[parameters('muteActionsDuration')]",
"actions": {
"actionGroups": [
"[parameters('actionGroupId')]"
],
"customProperties": {
"key1": "value1",
"key2": "value2"
}
}
}
}
]
}
Parameterfil
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "New Alert"
},
"location": {
"value": "eastus"
},
"alertDescription": {
"value": "New alert created via template"
},
"alertSeverity": {
"value":3
},
"isEnabled": {
"value": true
},
"resourceId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resourceGroup-name/providers/Microsoft.Compute/virtualMachines/replace-with-resource-name"
},
"query": {
"value": "Perf | where ObjectName == \"Processor\" and CounterName == \"% Processor Time\""
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-action-group"
}
}
}