Voorbeelden van Resource Manager-sjablonen voor metrische waarschuwingsregels in Azure Monitor
In dit artikel vindt u voorbeelden van hoe Azure Resource Manager-sjablonen gebruikt kunnen worden om metrische waarschuwingsregels te configureren in Azure Monitor. Elk voorbeeld bevat een sjabloonbestand en een parameterbestand met voorbeeldwaarden voor het sjabloon.
Notitie
Zie Azure Resource Manager-voorbeelden voor Azure Monitor voor een lijst met voorbeelden die beschikbaar zijn en richtlijnen voor het implementeren ervan in uw Azure-abonnement.
Bekijk Ondersteunde resources voor metrische waarschuwingen in Azure Monitor voor een lijst met resources die kunnen worden gebruikt met metrische waarschuwingsregels. Een uitleg van het schema en de eigenschappen voor een waarschuwingsregel is beschikbaar op Waarschuwingen voor metrische gegevens - maken of bijwerken.
Notitie
Resourcesjabloon voor het maken van metrische waarschuwingen voor het resourcetype: Azure Log Analytics-werkruimte (bijvoorbeeld) Microsoft.OperationalInsights/workspaces
vereist aanvullende stappen. Bekijk Metrische waarschuwing voor logboeken - Resourcesjabloon voor details.
Sjabloonverwijzingen
Eén criterium, statische drempelwaarde
Het volgende voorbeeld maakt een metrische waarschuwingsregel met één criterium en een statische drempelwaarde.
Sjabloonbestand
@description('Name of the alert')
@minLength(1)
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@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')
@minLength(1)
param resourceId string
@description('Name of the metric used in the comparison to activate the alert.')
@minLength(1)
param metricName string
@description('Operator comparing the current value with the threshold value.')
@allowed([
'Equals'
'GreaterThan'
'GreaterThanOrEqual'
'LessThan'
'LessThanOrEqual'
])
param operator string = 'GreaterThan'
@description('The threshold value at which the alert is activated.')
param threshold int = 0
@description('How the data that is collected should be combined over time.')
@allowed([
'Average'
'Minimum'
'Maximum'
'Total'
'Count'
])
param timeAggregation string = 'Average'
@description('Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format.')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
'PT6H'
'PT12H'
'PT24H'
])
param windowSize string = 'PT5M'
@description('how often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param evaluationFrequency string = 'PT1M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: [
resourceId
]
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria'
allOf: [
{
name: '1st criterion'
metricName: metricName
dimensions: []
operator: operator
threshold: threshold
timeAggregation: timeAggregation
criterionType: 'StaticThresholdCriterion'
}
]
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "New Metric Alert"
},
"alertDescription": {
"value": "New metric 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"
},
"metricName": {
"value": "Percentage CPU"
},
"operator": {
"value": "GreaterThan"
},
"threshold": {
"value": 80
},
"timeAggregation": {
"value": "Average"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-action-group"
}
}
}
Eén criterium, dynamische drempelwaarde
Het volgende voorbeeld maakt een metrische waarschuwingsregel met één criterium en een dynamische drempelwaarde.
Sjabloonbestand
@description('Name of the alert')
@minLength(1)
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@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')
@minLength(1)
param resourceId string
@description('Name of the metric used in the comparison to activate the alert.')
@minLength(1)
param metricName string
@description('Operator comparing the current value with the threshold value.')
@allowed([
'GreaterThan'
'LessThan'
'GreaterOrLessThan'
])
param operator string = 'GreaterOrLessThan'
@description('Tunes how \'noisy\' the Dynamic Thresholds alerts will be: \'High\' will result in more alerts while \'Low\' will result in fewer alerts.')
@allowed([
'High'
'Medium'
'Low'
])
param alertSensitivity string = 'Medium'
@description('The number of periods to check in the alert evaluation.')
param numberOfEvaluationPeriods int = 4
@description('The number of unhealthy periods to alert on (must be lower or equal to numberOfEvaluationPeriods).')
param minFailingPeriodsToAlert int = 3
@description('Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format, e.g. \'2019-12-31T22:00:00Z\').')
param ignoreDataBefore string = ''
@description('How the data that is collected should be combined over time.')
@allowed([
'Average'
'Minimum'
'Maximum'
'Total'
'Count'
])
param timeAggregation string = 'Average'
@description('Period of time used to monitor alert activity based on the threshold. Must be between five minutes and one hour. ISO 8601 duration format.')
@allowed([
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param windowSize string = 'PT5M'
@description('how often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param evaluationFrequency string = 'PT5M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: [
resourceId
]
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria'
allOf: [
{
criterionType: 'DynamicThresholdCriterion'
name: '1st criterion'
metricName: metricName
dimensions: []
operator: operator
alertSensitivity: alertSensitivity
failingPeriods: {
numberOfEvaluationPeriods: numberOfEvaluationPeriods
minFailingPeriodsToAlert: minFailingPeriodsToAlert
}
ignoreDataBefore: ignoreDataBefore
timeAggregation: timeAggregation
}
]
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "New Metric Alert with Dynamic Thresholds"
},
"alertDescription": {
"value": "New metric alert with Dynamic Thresholds 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"
},
"metricName": {
"value": "Percentage CPU"
},
"operator": {
"value": "GreaterOrLessThan"
},
"alertSensitivity": {
"value": "Medium"
},
"numberOfEvaluationPeriods": {
"value": "4"
},
"minFailingPeriodsToAlert": {
"value": "3"
},
"ignoreDataBefore": {
"value": ""
},
"timeAggregation": {
"value": "Average"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-action-group"
}
}
}
Meerdere criteria, statische drempelwaarde
Metrische waarschuwingen bieden ondersteuning voor waarschuwingen voor multidimensionale metrische gegevens en tot 5 criteria per waarschuwingsregel. In het volgende voorbeeld wordt een waarschuwingsregel voor metrische gegevens gemaakt voor dimensionale metrische gegevens en worden meerdere criteria opgegeven.
De volgende beperkingen gelden bij het gebruik van dimensies in een waarschuwingsregel die meerdere criteria bevat:
U kunt slechts één waarde per dimensie in elk criterium selecteren.
U kunt *niet gebruiken als dimensiewaarde.
Wanneer metrische gegevens die in verschillende criteria zijn geconfigureerd, dezelfde dimensie ondersteunen, moet een geconfigureerde dimensiewaarde expliciet op dezelfde manier worden ingesteld voor al deze metrische gegevens in de relevante criteria.
- In het onderstaande voorbeeld hebben zowel de metrische waarden Transactions en SuccessE2ELatency een dimensie ApiName en geeft criterion1 de waarde "GetBlob" voor de dimensie ApiName. Daarom moet criterion2 ook een waarde "GetBlob" hebben voor de dimensie ApiName.
Sjabloonbestand
@description('Name of the alert')
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@description('Resource ID of the resource emitting the metric that will be used for the comparison.')
param resourceId string = ''
@description('Criterion includes metric name, dimension values, threshold and an operator. The alert rule fires when ALL criteria are met')
param criterion1 object
@description('Criterion includes metric name, dimension values, threshold and an operator. The alert rule fires when ALL criteria are met')
param criterion2 object
@description('Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format.')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
'PT6H'
'PT12H'
'PT24H'
])
param windowSize string = 'PT5M'
@description('how often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param evaluationFrequency string = 'PT1M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
var criterion1_var = array(criterion1)
var criterion2_var = array(criterion2)
var criteria = concat(criterion1_var, criterion2_var)
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: [
resourceId
]
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria'
allOf: criteria
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "New Multi-dimensional Metric Alert (Replace with your alert name)"
},
"alertDescription": {
"value": "New multi-dimensional metric alert created via template (Replace with your alert description)"
},
"alertSeverity": {
"value": 3
},
"isEnabled": {
"value": true
},
"resourceId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resourcegroup-name/providers/Microsoft.Storage/storageAccounts/replace-with-storage-account"
},
"criterion1": {
"value": {
"name": "1st criterion",
"metricName": "Transactions",
"dimensions": [
{
"name": "ResponseType",
"operator": "Include",
"values": [ "Success" ]
},
{
"name": "ApiName",
"operator": "Include",
"values": [ "GetBlob" ]
}
],
"operator": "GreaterThan",
"threshold": 5,
"timeAggregation": "Total"
}
},
"criterion2": {
"value": {
"name": "2nd criterion",
"metricName": "SuccessE2ELatency",
"dimensions": [
{
"name": "ApiName",
"operator": "Include",
"values": [ "GetBlob" ]
}
],
"operator": "GreaterThan",
"threshold": 250,
"timeAggregation": "Average"
}
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-actiongroup-name"
}
}
}
Meerdere dimensies, statische drempelwaarde
Eén waarschuwingsregel kan meerdere metrische tijdreeksen tegelijk controleren, waardoor er minder waarschuwingsregels beheerd moeten worden. Het volgende voorbeeld maakt een statische metrische waarschuwingsregel voor dimensionale metrische gegevens.
In dit voorbeeld controleert de waarschuwingsregel de dimensiewaardecombinaties van de dimensies ResponsType en ApiName voor de meetwaarde Transactions:
- ResponsType : het gebruik van het jokerteken '*' betekent dat voor elke waarde van de dimensie ResponseType , inclusief toekomstige waarden, een andere tijdreeks afzonderlijk wordt bewaakt.
- ApiName: er wordt een andere tijdreeks gecontroleerd alleen voor de dimensiewaarden GetBlob en PutBlob.
Enkele mogelijke tijdreeksen die gecontroleerd worden door deze waarschuwingsregel zijn bijvoorbeeld:
- Metric = Transactions, ResponseType = Success, ApiName = GetBlob
- Metric = Transactions, ResponseType = Success, ApiName = PutBlob
- Metric = Transactions, ResponseType = Server Timeout, ApiName = GetBlob
- Metric = Transactions, ResponseType = Server Timeout, ApiName = PutBlob
Sjabloonbestand
@description('Name of the alert')
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@description('Resource ID of the resource emitting the metric that will be used for the comparison.')
param resourceId string = ''
@description('Criterion includes metric name, dimension values, threshold and an operator. The alert rule fires when ALL criteria are met')
param criterion object
@description('Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format.')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
'PT6H'
'PT12H'
'PT24H'
])
param windowSize string = 'PT5M'
@description('how often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param evaluationFrequency string = 'PT1M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
var criteria = array(criterion)
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: [
resourceId
]
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria'
allOf: criteria
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "New multi-dimensional metric alert rule (replace with your alert name)"
},
"alertDescription": {
"value": "New multi-dimensional metric alert rule created via template (replace with your alert description)"
},
"alertSeverity": {
"value": 3
},
"isEnabled": {
"value": true
},
"resourceId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resourcegroup-name/providers/Microsoft.Storage/storageAccounts/replace-with-storage-account"
},
"criterion": {
"value": {
"name": "Criterion",
"metricName": "Transactions",
"dimensions": [
{
"name": "ResponseType",
"operator": "Include",
"values": [ "*" ]
},
{
"name": "ApiName",
"operator": "Include",
"values": [ "GetBlob", "PutBlob" ]
}
],
"operator": "GreaterThan",
"threshold": 5,
"timeAggregation": "Total"
}
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-actiongroup-name"
}
}
}
Notitie
Het gebruik van 'Alles' als dimensiewaarde is gelijk aan het selecteren van '*' (alle huidige en toekomstige waarden).
Meerdere dimensies, dynamische drempelwaarde
Eén waarschuwingsregel voor dynamische drempelwaarden kan aangepaste drempelwaarden maken voor honderden metrische tijdreeksen (zelfs verschillende typen) tegelijkertijd, waardoor er minder waarschuwingsregels beheerd moeten worden. Het volgende voorbeeld maakt een waarschuwingsregel voor dynamische drempelwaarden met dimensionale metrische gegevens.
In dit voorbeeld controleert de waarschuwingsregel de dimensiewaardecombinaties van de dimensies ResponsType en ApiName voor de meetwaarde Transactions:
- ResponsType: voor elke waarde van de dimensie ResponseType, inclusief toekomstige waarden, wordt een andere tijdreeks individueel bewaakt.
- ApiName: er wordt een andere tijdreeks gecontroleerd alleen voor de dimensiewaarden GetBlob en PutBlob.
Enkele mogelijke tijdreeksen die gecontroleerd worden door deze waarschuwingsregel zijn bijvoorbeeld:
- Metric = Transactions, ResponseType = Success, ApiName = GetBlob
- Metric = Transactions, ResponseType = Success, ApiName = PutBlob
- Metric = Transactions, ResponseType = Server Timeout, ApiName = GetBlob
- Metric = Transactions, ResponseType = Server Timeout, ApiName = PutBlob
Notitie
Meerdere criteria worden momenteel niet ondersteund voor metrische waarschuwingsregels die dynamische drempelwaarden gebruiken.
Sjabloonbestand
@description('Name of the alert')
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@description('Resource ID of the resource emitting the metric that will be used for the comparison.')
param resourceId string = ''
@description('Criterion includes metric name, dimension values, threshold and an operator.')
param criterion object
@description('Period of time used to monitor alert activity based on the threshold. Must be between five minutes and one hour. ISO 8601 duration format.')
@allowed([
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param windowSize string = 'PT5M'
@description('how often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param evaluationFrequency string = 'PT5M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
var criteria = array(criterion)
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: [
resourceId
]
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria'
allOf: criteria
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "New Multi-dimensional Metric Alert with Dynamic Thresholds (Replace with your alert name)"
},
"alertDescription": {
"value": "New multi-dimensional metric alert with Dynamic Thresholds created via template (Replace with your alert description)"
},
"alertSeverity": {
"value": 3
},
"isEnabled": {
"value": true
},
"resourceId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resourcegroup-name/providers/Microsoft.Storage/storageAccounts/replace-with-storage-account"
},
"criterion": {
"value": {
"criterionType": "DynamicThresholdCriterion",
"name": "1st criterion",
"metricName": "Transactions",
"dimensions": [
{
"name": "ResponseType",
"operator": "Include",
"values": [ "*" ]
},
{
"name": "ApiName",
"operator": "Include",
"values": [ "GetBlob", "PutBlob" ]
}
],
"operator": "GreaterOrLessThan",
"alertSensitivity": "Medium",
"failingPeriods": {
"numberOfEvaluationPeriods": "4",
"minFailingPeriodsToAlert": "3"
},
"timeAggregation": "Total"
}
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-actiongroup-name"
}
}
}
Aangepaste meetwaarde, statische drempelwaarde
U kunt het volgende sjabloon gebruiken om een meer geavanceerde waarschuwingsregel voor metrische gegevens met statische drempelwaarde te maken voor aangepaste metrische gegevens.
Bekijk Aangepaste metrische gegevens in Azure Monitor voor meer informatie over aangepaste metrische gegevens in Azure Monitor.
Wanneer u een waarschuwingsregel maakt voor aangepaste metrische gegevens, moet u zowel de metrische naam als de metrische naamruimte opgeven. Zorg er ook voor dat er al over de aangepaste metrische gegevens wordt gerapporteerd, want u kunt geen waarschuwingsregel maken voor aangepaste metrische gegevens die nog niet bestaan.
Sjabloonbestand
@description('Name of the alert')
@minLength(1)
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@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')
@minLength(1)
param resourceId string
@description('Name of the metric used in the comparison to activate the alert.')
@minLength(1)
param metricName string
@description('Namespace of the metric used in the comparison to activate the alert.')
@minLength(1)
param metricNamespace string
@description('Operator comparing the current value with the threshold value.')
@allowed([
'Equals'
'GreaterThan'
'GreaterThanOrEqual'
'LessThan'
'LessThanOrEqual'
])
param operator string = 'GreaterThan'
@description('The threshold value at which the alert is activated.')
param threshold int = 0
@description('How the data that is collected should be combined over time.')
@allowed([
'Average'
'Minimum'
'Maximum'
'Total'
'Count'
])
param timeAggregation string = 'Average'
@description('Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format.')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
'PT6H'
'PT12H'
'PT24H'
])
param windowSize string = 'PT5M'
@description('How often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param evaluationFrequency string = 'PT1M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: [
resourceId
]
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria'
allOf: [
{
name: '1st criterion'
metricName: metricName
metricNamespace: metricNamespace
dimensions: []
operator: operator
threshold: threshold
timeAggregation: timeAggregation
criterionType: 'StaticThresholdCriterion'
}
]
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "New alert rule on a custom metric"
},
"alertDescription": {
"value": "New alert rule on a custom metric created via template"
},
"alertSeverity": {
"value": 3
},
"isEnabled": {
"value": true
},
"resourceId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resourceGroup-name/providers/microsoft.insights/components/replace-with-application-insights-resource-name"
},
"metricName": {
"value": "The custom metric name"
},
"metricNamespace": {
"value": "Azure.ApplicationInsights"
},
"operator": {
"value": "GreaterThan"
},
"threshold": {
"value": 80
},
"timeAggregation": {
"value": "Average"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-action-group"
}
}
}
Notitie
U vindt de metrische naamruimte van specifieke aangepaste metrische gegevens door te zoeken naar uw aangepaste metrische gegevens via het Azure-portal
Meerdere resources
Azure Monitor ondersteunt het controleren van meerdere resources van hetzelfde type met één regel voor metrische waarschuwingen, voor resources die bestaan in dezelfde Azure-regio. Deze functie wordt momenteel alleen ondersteund in de openbare Azure-cloud en alleen voor virtuele machines, SQL Server-databases, elastische pools van SQL Server en Azure Stack Edge-apparaten. Daarnaast is deze functie enkel beschikbaar voor metrische gegevens op platforms en niet voor aangepaste metrische gegevens.
Waarschuwingsregels voor dynamische drempelwaarden kunnen ook helpen om aangepaste drempelwaarden te maken voor honderden metrische reeksen (zelfs verschillende typen) tegelijkertijd, waardoor er minder waarschuwingsregels beheerd moeten worden.
In deze sectie worden Azure Resource Manager-sjablonen beschreven voor drie scenario's om meerdere resources te controleren met één regel.
- Alle virtuele machines (in één Azure-regio) in een of meer resourcegroepen controleren.
- Alle virtuele machines (in één Azure-regio) in een abonnement controleren.
- Een lijst met virtuele machines (in één Azure-regio) in een abonnement controleren.
Notitie
- In een metrische waarschuwingsregel die meerdere resources controleert is slechts één voorwaarde toegestaan.
- Als u een metrische waarschuwing voor één resource maakt, gebruikt de sjabloon de
ResourceId
doelresource. Als u een metrische waarschuwing voor meerdere resources maakt, gebruikt de sjabloon descope
,TargetResourceType
enTargetResourceRegion
voor de doelbronnen.
Waarschuwing voor een statische drempelwaarde voor alle virtuele machines in een of meer resourcegroepen
Dit sjabloon maakt een metrische waarschuwingsregel voor een statische drempelwaarde die het CPU-percentage controleert voor alle virtuele machines (in één Azure-regio) in een of meer resourcegroepen.
Sla de onderstaande json op als all-vms-in-resource-group-static.json voor deze stapsgewijze handleiding.
Sjabloonbestand
@description('Name of the alert')
@minLength(1)
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@description('Full path of the resource group(s) where target resources to be monitored are in. For example - /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroups/ResourceGroupName')
@minLength(1)
param targetResourceGroup array
@description('Azure region in which target resources to be monitored are in (without spaces). For example: EastUS')
@allowed([
'EastUS'
'EastUS2'
'CentralUS'
'NorthCentralUS'
'SouthCentralUS'
'WestCentralUS'
'WestUS'
'WestUS2'
'CanadaEast'
'CanadaCentral'
'BrazilSouth'
'NorthEurope'
'WestEurope'
'FranceCentral'
'FranceSouth'
'UKWest'
'UKSouth'
'GermanyCentral'
'GermanyNortheast'
'GermanyNorth'
'GermanyWestCentral'
'SwitzerlandNorth'
'SwitzerlandWest'
'NorwayEast'
'NorwayWest'
'SoutheastAsia'
'EastAsia'
'AustraliaEast'
'AustraliaSoutheast'
'AustraliaCentral'
'AustraliaCentral2'
'ChinaEast'
'ChinaNorth'
'ChinaEast2'
'ChinaNorth2'
'CentralIndia'
'WestIndia'
'SouthIndia'
'JapanEast'
'JapanWest'
'KoreaCentral'
'KoreaSouth'
'SouthAfricaWest'
'SouthAfricaNorth'
'UAECentral'
'UAENorth'
])
param targetResourceRegion string
@description('Resource type of target resources to be monitored.')
@minLength(1)
param targetResourceType string
@description('Name of the metric used in the comparison to activate the alert.')
@minLength(1)
param metricName string
@description('Operator comparing the current value with the threshold value.')
@allowed([
'Equals'
'GreaterThan'
'GreaterThanOrEqual'
'LessThan'
'LessThanOrEqual'
])
param operator string = 'GreaterThan'
@description('The threshold value at which the alert is activated.')
param threshold string = '0'
@description('How the data that is collected should be combined over time.')
@allowed([
'Average'
'Minimum'
'Maximum'
'Total'
'Count'
])
param timeAggregation string = 'Average'
@description('Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format.')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
'PT6H'
'PT12H'
'PT24H'
])
param windowSize string = 'PT5M'
@description('how often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
])
param evaluationFrequency string = 'PT1M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: targetResourceGroup
targetResourceType: targetResourceType
targetResourceRegion: targetResourceRegion
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria'
allOf: [
{
name: '1st criterion'
metricName: metricName
dimensions: []
operator: operator
threshold: threshold
timeAggregation: timeAggregation
criterionType: 'StaticThresholdCriterion'
}
]
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "Multi-resource metric alert via Azure Resource Manager template"
},
"alertDescription": {
"value": "New Multi-resource metric alert created via template"
},
"alertSeverity": {
"value": 3
},
"isEnabled": {
"value": true
},
"targetResourceGroup": {
"value": [
"/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name1",
"/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name2"
]
},
"targetResourceRegion": {
"value": "SouthCentralUS"
},
"targetResourceType": {
"value": "Microsoft.Compute/virtualMachines"
},
"metricName": {
"value": "Percentage CPU"
},
"operator": {
"value": "GreaterThan"
},
"threshold": {
"value": 0
},
"timeAggregation": {
"value": "Average"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-action-group-name"
}
}
}
Waarschuwingen voor een dynamische drempelwaarden voor alle virtuele machines in een of meer resourcegroepen
Dit voorbeeld maakt een metrische waarschuwingsregel voor een dynamische drempelwaarde die het CPU-percentage controleert voor alle virtuele machines in één Azure-regio in een of meer resourcegroepen.
Sjabloonbestand
@description('Name of the alert')
@minLength(1)
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@description('Full path of the resource group(s) where target resources to be monitored are in. For example - /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroups/ResourceGroupName')
@minLength(1)
param targetResourceGroup array
@description('Azure region in which target resources to be monitored are in (without spaces). For example: EastUS')
@allowed([
'EastUS'
'EastUS2'
'CentralUS'
'NorthCentralUS'
'SouthCentralUS'
'WestCentralUS'
'WestUS'
'WestUS2'
'CanadaEast'
'CanadaCentral'
'BrazilSouth'
'NorthEurope'
'WestEurope'
'FranceCentral'
'FranceSouth'
'UKWest'
'UKSouth'
'GermanyCentral'
'GermanyNortheast'
'GermanyNorth'
'GermanyWestCentral'
'SwitzerlandNorth'
'SwitzerlandWest'
'NorwayEast'
'NorwayWest'
'SoutheastAsia'
'EastAsia'
'AustraliaEast'
'AustraliaSoutheast'
'AustraliaCentral'
'AustraliaCentral2'
'ChinaEast'
'ChinaNorth'
'ChinaEast2'
'ChinaNorth2'
'CentralIndia'
'WestIndia'
'SouthIndia'
'JapanEast'
'JapanWest'
'KoreaCentral'
'KoreaSouth'
'SouthAfricaWest'
'SouthAfricaNorth'
'UAECentral'
'UAENorth'
])
param targetResourceRegion string
@description('Resource type of target resources to be monitored.')
@minLength(1)
param targetResourceType string
@description('Name of the metric used in the comparison to activate the alert.')
@minLength(1)
param metricName string
@description('Operator comparing the current value with the threshold value.')
@allowed([
'GreaterThan'
'LessThan'
'GreaterOrLessThan'
])
param operator string = 'GreaterOrLessThan'
@description('Tunes how \'noisy\' the Dynamic Thresholds alerts will be: \'High\' will result in more alerts while \'Low\' will result in fewer alerts.')
@allowed([
'High'
'Medium'
'Low'
])
param alertSensitivity string = 'Medium'
@description('The number of periods to check in the alert evaluation.')
param numberOfEvaluationPeriods int = 4
@description('The number of unhealthy periods to alert on (must be lower or equal to numberOfEvaluationPeriods).')
param minFailingPeriodsToAlert int = 3
@description('How the data that is collected should be combined over time.')
@allowed([
'Average'
'Minimum'
'Maximum'
'Total'
'Count'
])
param timeAggregation string = 'Average'
@description('Period of time used to monitor alert activity based on the threshold. Must be between five minutes and one hour. ISO 8601 duration format.')
@allowed([
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param windowSize string = 'PT5M'
@description('how often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param evaluationFrequency string = 'PT5M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: targetResourceGroup
targetResourceType: targetResourceType
targetResourceRegion: targetResourceRegion
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria'
allOf: [
{
criterionType: 'DynamicThresholdCriterion'
name: '1st criterion'
metricName: metricName
dimensions: []
operator: operator
alertSensitivity: alertSensitivity
failingPeriods: {
numberOfEvaluationPeriods: numberOfEvaluationPeriods
minFailingPeriodsToAlert: minFailingPeriodsToAlert
}
timeAggregation: timeAggregation
}
]
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "Multi-resource metric alert with Dynamic Thresholds via Azure Resource Manager template"
},
"alertDescription": {
"value": "New Multi-resource metric alert with Dynamic Thresholds created via template"
},
"alertSeverity": {
"value": 3
},
"isEnabled": {
"value": true
},
"targetResourceGroup": {
"value": [
"/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name1",
"/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name2"
]
},
"targetResourceRegion": {
"value": "SouthCentralUS"
},
"targetResourceType": {
"value": "Microsoft.Compute/virtualMachines"
},
"metricName": {
"value": "Percentage CPU"
},
"operator": {
"value": "GreaterOrLessThan"
},
"alertSensitivity": {
"value": "Medium"
},
"numberOfEvaluationPeriods": {
"value": "4"
},
"minFailingPeriodsToAlert": {
"value": "3"
},
"timeAggregation": {
"value": "Average"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-action-group-name"
}
}
}
Waarschuwing voor een statische drempelwaarde voor alle virtuele machines in een abonnement
Dit voorbeeld maakt een metrische waarschuwingsregel voor een statische drempelwaarde die het CPU-percentage controleert voor alle virtuele machines in één Azure-regio in een abonnement.
Sjabloonbestand
@description('Name of the alert')
@minLength(1)
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@description('Azure Resource Manager path up to subscription ID. For example - /subscriptions/00000000-0000-0000-0000-0000-00000000')
@minLength(1)
param targetSubscription string
@description('Azure region in which target resources to be monitored are in (without spaces). For example: EastUS')
@allowed([
'EastUS'
'EastUS2'
'CentralUS'
'NorthCentralUS'
'SouthCentralUS'
'WestCentralUS'
'WestUS'
'WestUS2'
'CanadaEast'
'CanadaCentral'
'BrazilSouth'
'NorthEurope'
'WestEurope'
'FranceCentral'
'FranceSouth'
'UKWest'
'UKSouth'
'GermanyCentral'
'GermanyNortheast'
'GermanyNorth'
'GermanyWestCentral'
'SwitzerlandNorth'
'SwitzerlandWest'
'NorwayEast'
'NorwayWest'
'SoutheastAsia'
'EastAsia'
'AustraliaEast'
'AustraliaSoutheast'
'AustraliaCentral'
'AustraliaCentral2'
'ChinaEast'
'ChinaNorth'
'ChinaEast2'
'ChinaNorth2'
'CentralIndia'
'WestIndia'
'SouthIndia'
'JapanEast'
'JapanWest'
'KoreaCentral'
'KoreaSouth'
'SouthAfricaWest'
'SouthAfricaNorth'
'UAECentral'
'UAENorth'
])
param targetResourceRegion string
@description('Resource type of target resources to be monitored.')
@minLength(1)
param targetResourceType string
@description('Name of the metric used in the comparison to activate the alert.')
@minLength(1)
param metricName string
@description('Operator comparing the current value with the threshold value.')
@allowed([
'Equals'
'GreaterThan'
'GreaterThanOrEqual'
'LessThan'
'LessThanOrEqual'
])
param operator string = 'GreaterThan'
@description('The threshold value at which the alert is activated.')
param threshold string = '0'
@description('How the data that is collected should be combined over time.')
@allowed([
'Average'
'Minimum'
'Maximum'
'Total'
'Count'
])
param timeAggregation string = 'Average'
@description('Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format.')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
'PT6H'
'PT12H'
'PT24H'
])
param windowSize string = 'PT5M'
@description('how often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param evaluationFrequency string = 'PT1M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: [
targetSubscription
]
targetResourceType: targetResourceType
targetResourceRegion: targetResourceRegion
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria'
allOf: [
{
name: '1st criterion'
metricName: metricName
dimensions: []
operator: operator
threshold: threshold
timeAggregation: timeAggregation
criterionType: 'StaticThresholdCriterion'
}
]
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "Multi-resource sub level metric alert via Azure Resource Manager template"
},
"alertDescription": {
"value": "New Multi-resource sub level metric alert created via template"
},
"alertSeverity": {
"value": 3
},
"isEnabled": {
"value": true
},
"targetSubscription": {
"value": "/subscriptions/replace-with-subscription-id"
},
"targetResourceRegion": {
"value": "SouthCentralUS"
},
"targetResourceType": {
"value": "Microsoft.Compute/virtualMachines"
},
"metricName": {
"value": "Percentage CPU"
},
"operator": {
"value": "GreaterThan"
},
"threshold": {
"value": 0
},
"timeAggregation": {
"value": "Average"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-action-group-name"
}
}
}
Waarschuwing voor een dynamische drempelwaarde voor alle virtuele machines in een abonnement
Dit voorbeeld maakt een metrische waarschuwingsregel voor een dynamische drempelwaarde die het CPU-percentage controleert voor alle virtuele machines in één Azure-regio in een abonnement.
Sjabloonbestand
@description('Name of the alert')
@minLength(1)
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@description('Azure Resource Manager path up to subscription ID. For example - /subscriptions/00000000-0000-0000-0000-0000-00000000')
@minLength(1)
param targetSubscription string
@description('Azure region in which target resources to be monitored are in (without spaces). For example: EastUS')
@allowed([
'EastUS'
'EastUS2'
'CentralUS'
'NorthCentralUS'
'SouthCentralUS'
'WestCentralUS'
'WestUS'
'WestUS2'
'CanadaEast'
'CanadaCentral'
'BrazilSouth'
'NorthEurope'
'WestEurope'
'FranceCentral'
'FranceSouth'
'UKWest'
'UKSouth'
'GermanyCentral'
'GermanyNortheast'
'GermanyNorth'
'GermanyWestCentral'
'SwitzerlandNorth'
'SwitzerlandWest'
'NorwayEast'
'NorwayWest'
'SoutheastAsia'
'EastAsia'
'AustraliaEast'
'AustraliaSoutheast'
'AustraliaCentral'
'AustraliaCentral2'
'ChinaEast'
'ChinaNorth'
'ChinaEast2'
'ChinaNorth2'
'CentralIndia'
'WestIndia'
'SouthIndia'
'JapanEast'
'JapanWest'
'KoreaCentral'
'KoreaSouth'
'SouthAfricaWest'
'SouthAfricaNorth'
'UAECentral'
'UAENorth'
])
param targetResourceRegion string
@description('Resource type of target resources to be monitored.')
@minLength(1)
param targetResourceType string
@description('Name of the metric used in the comparison to activate the alert.')
@minLength(1)
param metricName string
@description('Operator comparing the current value with the threshold value.')
@allowed([
'GreaterThan'
'LessThan'
'GreaterOrLessThan'
])
param operator string = 'GreaterOrLessThan'
@description('Tunes how \'noisy\' the Dynamic Thresholds alerts will be: \'High\' will result in more alerts while \'Low\' will result in fewer alerts.')
@allowed([
'High'
'Medium'
'Low'
])
param alertSensitivity string = 'Medium'
@description('The number of periods to check in the alert evaluation.')
param numberOfEvaluationPeriods int = 4
@description('The number of unhealthy periods to alert on (must be lower or equal to numberOfEvaluationPeriods).')
param minFailingPeriodsToAlert int = 3
@description('How the data that is collected should be combined over time.')
@allowed([
'Average'
'Minimum'
'Maximum'
'Total'
'Count'
])
param timeAggregation string = 'Average'
@description('Period of time used to monitor alert activity based on the threshold. Must be between five minutes and one hour. ISO 8601 duration format.')
@allowed([
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param windowSize string = 'PT5M'
@description('how often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param evaluationFrequency string = 'PT5M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: [
targetSubscription
]
targetResourceType: targetResourceType
targetResourceRegion: targetResourceRegion
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria'
allOf: [
{
criterionType: 'DynamicThresholdCriterion'
name: '1st criterion'
metricName: metricName
dimensions: []
operator: operator
alertSensitivity: alertSensitivity
failingPeriods: {
numberOfEvaluationPeriods: numberOfEvaluationPeriods
minFailingPeriodsToAlert: minFailingPeriodsToAlert
}
timeAggregation: timeAggregation
}
]
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "Multi-resource sub level metric alert with Dynamic Thresholds via Azure Resource Manager template"
},
"alertDescription": {
"value": "New Multi-resource sub level metric alert with Dynamic Thresholds created via template"
},
"alertSeverity": {
"value": 3
},
"isEnabled": {
"value": true
},
"targetSubscription": {
"value": "/subscriptions/replace-with-subscription-id"
},
"targetResourceRegion": {
"value": "SouthCentralUS"
},
"targetResourceType": {
"value": "Microsoft.Compute/virtualMachines"
},
"metricName": {
"value": "Percentage CPU"
},
"operator": {
"value": "GreaterOrLessThan"
},
"alertSensitivity": {
"value": "Medium"
},
"numberOfEvaluationPeriods": {
"value": "4"
},
"minFailingPeriodsToAlert": {
"value": "3"
},
"timeAggregation": {
"value": "Average"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-action-group-name"
}
}
}
Waarschuwing voor een statische drempelwaarde voor een lijst van virtuele machines
Dit voorbeeld maakt een metrische waarschuwingsregel voor een statische drempelwaarde die het CPU-percentage controleert voor een lijst van virtuele machines in één Azure-regio in een abonnement.
Sjabloonbestand
@description('Name of the alert')
@minLength(1)
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@description('array of Azure resource Ids. For example - /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroup/resource-group-name/Microsoft.compute/virtualMachines/vm-name')
@minLength(1)
param targetResourceId array
@description('Azure region in which target resources to be monitored are in (without spaces). For example: EastUS')
@allowed([
'EastUS'
'EastUS2'
'CentralUS'
'NorthCentralUS'
'SouthCentralUS'
'WestCentralUS'
'WestUS'
'WestUS2'
'CanadaEast'
'CanadaCentral'
'BrazilSouth'
'NorthEurope'
'WestEurope'
'FranceCentral'
'FranceSouth'
'UKWest'
'UKSouth'
'GermanyCentral'
'GermanyNortheast'
'GermanyNorth'
'GermanyWestCentral'
'SwitzerlandNorth'
'SwitzerlandWest'
'NorwayEast'
'NorwayWest'
'SoutheastAsia'
'EastAsia'
'AustraliaEast'
'AustraliaSoutheast'
'AustraliaCentral'
'AustraliaCentral2'
'ChinaEast'
'ChinaNorth'
'ChinaEast2'
'ChinaNorth2'
'CentralIndia'
'WestIndia'
'SouthIndia'
'JapanEast'
'JapanWest'
'KoreaCentral'
'KoreaSouth'
'SouthAfricaWest'
'SouthAfricaNorth'
'UAECentral'
'UAENorth'
])
param targetResourceRegion string
@description('Resource type of target resources to be monitored.')
@minLength(1)
param targetResourceType string
@description('Name of the metric used in the comparison to activate the alert.')
@minLength(1)
param metricName string
@description('Operator comparing the current value with the threshold value.')
@allowed([
'Equals'
'GreaterThan'
'GreaterThanOrEqual'
'LessThan'
'LessThanOrEqual'
])
param operator string = 'GreaterThan'
@description('The threshold value at which the alert is activated.')
param threshold string = '0'
@description('How the data that is collected should be combined over time.')
@allowed([
'Average'
'Minimum'
'Maximum'
'Total'
'Count'
])
param timeAggregation string = 'Average'
@description('Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format.')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
'PT6H'
'PT12H'
'PT24H'
])
param windowSize string = 'PT5M'
@description('how often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT1M'
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param evaluationFrequency string = 'PT1M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: targetResourceId
targetResourceType: targetResourceType
targetResourceRegion: targetResourceRegion
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria'
allOf: [
{
name: '1st criterion'
metricName: metricName
dimensions: []
operator: operator
threshold: threshold
timeAggregation: timeAggregation
criterionType: 'StaticThresholdCriterion'
}
]
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "Multi-resource metric alert by list via Azure Resource Manager template"
},
"alertDescription": {
"value": "New Multi-resource metric alert by list created via template"
},
"alertSeverity": {
"value": 3
},
"isEnabled": {
"value": true
},
"targetResourceId": {
"value": [
"/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name1/Microsoft.Compute/virtualMachines/replace-with-vm-name1",
"/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name2/Microsoft.Compute/virtualMachines/replace-with-vm-name2"
]
},
"targetResourceRegion": {
"value": "SouthCentralUS"
},
"targetResourceType": {
"value": "Microsoft.Compute/virtualMachines"
},
"metricName": {
"value": "Percentage CPU"
},
"operator": {
"value": "GreaterThan"
},
"threshold": {
"value": 0
},
"timeAggregation": {
"value": "Average"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-action-group-name"
}
}
}
Waarschuwing voor een dynamische drempelwaarde voor een lijst van virtuele machines
Dit voorbeeld maakt een metrische waarschuwingsregel voor een dynamische drempelwaarde die het CPU-percentage controleert voor een lijst van virtuele machines in één Azure-regio in een abonnement.
Sjabloonbestand
@description('Name of the alert')
@minLength(1)
param alertName string
@description('Description of alert')
param alertDescription string = 'This is a metric alert'
@description('Severity of alert {0,1,2,3,4}')
@allowed([
0
1
2
3
4
])
param alertSeverity int = 3
@description('Specifies whether the alert is enabled')
param isEnabled bool = true
@description('array of Azure resource Ids. For example - /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroup/resource-group-name/Microsoft.compute/virtualMachines/vm-name')
@minLength(1)
param targetResourceId array
@description('Azure region in which target resources to be monitored are in (without spaces). For example: EastUS')
@allowed([
'EastUS'
'EastUS2'
'CentralUS'
'NorthCentralUS'
'SouthCentralUS'
'WestCentralUS'
'WestUS'
'WestUS2'
'CanadaEast'
'CanadaCentral'
'BrazilSouth'
'NorthEurope'
'WestEurope'
'FranceCentral'
'FranceSouth'
'UKWest'
'UKSouth'
'GermanyCentral'
'GermanyNortheast'
'GermanyNorth'
'GermanyWestCentral'
'SwitzerlandNorth'
'SwitzerlandWest'
'NorwayEast'
'NorwayWest'
'SoutheastAsia'
'EastAsia'
'AustraliaEast'
'AustraliaSoutheast'
'AustraliaCentral'
'AustraliaCentral2'
'ChinaEast'
'ChinaNorth'
'ChinaEast2'
'ChinaNorth2'
'CentralIndia'
'WestIndia'
'SouthIndia'
'JapanEast'
'JapanWest'
'KoreaCentral'
'KoreaSouth'
'SouthAfricaWest'
'SouthAfricaNorth'
'UAECentral'
'UAENorth'
])
param targetResourceRegion string
@description('Resource type of target resources to be monitored.')
@minLength(1)
param targetResourceType string
@description('Name of the metric used in the comparison to activate the alert.')
@minLength(1)
param metricName string
@description('Operator comparing the current value with the threshold value.')
@allowed([
'GreaterThan'
'LessThan'
'GreaterOrLessThan'
])
param operator string = 'GreaterOrLessThan'
@description('Tunes how \'noisy\' the Dynamic Thresholds alerts will be: \'High\' will result in more alerts while \'Low\' will result in fewer alerts.')
@allowed([
'High'
'Medium'
'Low'
])
param alertSensitivity string = 'Medium'
@description('The number of periods to check in the alert evaluation.')
param numberOfEvaluationPeriods int = 4
@description('The number of unhealthy periods to alert on (must be lower or equal to numberOfEvaluationPeriods).')
param minFailingPeriodsToAlert int = 3
@description('How the data that is collected should be combined over time.')
@allowed([
'Average'
'Minimum'
'Maximum'
'Total'
'Count'
])
param timeAggregation string = 'Average'
@description('Period of time used to monitor alert activity based on the threshold. Must be between five minutes and one hour. ISO 8601 duration format.')
@allowed([
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param windowSize string = 'PT5M'
@description('how often the metric alert is evaluated represented in ISO 8601 duration format')
@allowed([
'PT5M'
'PT15M'
'PT30M'
'PT1H'
])
param evaluationFrequency string = 'PT5M'
@description('The ID of the action group that is triggered when the alert is activated or deactivated')
param actionGroupId string = ''
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: alertName
location: 'global'
properties: {
description: alertDescription
severity: alertSeverity
enabled: isEnabled
scopes: targetResourceId
targetResourceType: targetResourceType
targetResourceRegion: targetResourceRegion
evaluationFrequency: evaluationFrequency
windowSize: windowSize
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria'
allOf: [
{
criterionType: 'DynamicThresholdCriterion'
name: '1st criterion'
metricName: metricName
dimensions: []
operator: operator
alertSensitivity: alertSensitivity
failingPeriods: {
numberOfEvaluationPeriods: numberOfEvaluationPeriods
minFailingPeriodsToAlert: minFailingPeriodsToAlert
}
timeAggregation: timeAggregation
}
]
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "Multi-resource metric alert with Dynamic Thresholds by list via Azure Resource Manager template"
},
"alertDescription": {
"value": "New Multi-resource metric alert with Dynamic Thresholds by list created via template"
},
"alertSeverity": {
"value": 3
},
"isEnabled": {
"value": true
},
"targetResourceId": {
"value": [
"/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name1/Microsoft.Compute/virtualMachines/replace-with-vm-name1",
"/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name2/Microsoft.Compute/virtualMachines/replace-with-vm-name2"
]
},
"targetResourceRegion": {
"value": "SouthCentralUS"
},
"targetResourceType": {
"value": "Microsoft.Compute/virtualMachines"
},
"metricName": {
"value": "Percentage CPU"
},
"operator": {
"value": "GreaterOrLessThan"
},
"alertSensitivity": {
"value": "Medium"
},
"numberOfEvaluationPeriods": {
"value": "4"
},
"minFailingPeriodsToAlert": {
"value": "3"
},
"timeAggregation": {
"value": "Average"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-action-group-name"
}
}
}
Beschikbaarheidstest met metrische waarschuwing
Beschikbaarheidstests voor Application Insights helpen u om de beschikbaarheid van uw website/app vanaf verschillende locaties wereldwijd te controleren. U ontvangt een waarschuwing van de beschikbaarheidstest wanneer deze mislukt vanaf een bepaald aantal locaties. Waarschuwingen van beschikbaarheidstests van hetzelfde resourcetype als waarschuwingen voor metrische gegevens (Microsoft.Insights/metricAlerts). Het volgende voorbeeld maakt een eenvoudige beschikbaarheidstest en een bijbehorende waarschuwing.
Notitie
&
; is de HTML-entiteitsverwijzing voor &. URL-parameters worden nog steeds gescheiden door één &, maar als u de URL vermeldt in HTML moet u deze coderen. Als er dus een '&' staat in uw parameterwaarde voor pingURL dan moet u "&
;" gebruiken als escapeteken.
Sjabloonbestand
param appName string
param pingURL string
param pingText string = ''
param actionGroupId string
param location string
var pingTestName = 'PingTest-${toLower(appName)}'
var pingAlertRuleName = 'PingAlert-${toLower(appName)}-${subscription().subscriptionId}'
resource pingTest 'Microsoft.Insights/webtests@2020-10-05-preview' = {
name: pingTestName
location: location
tags: {
'hidden-link:${resourceId('Microsoft.Insights/components', appName)}': 'Resource'
}
properties: {
Name: pingTestName
Description: 'Basic ping test'
Enabled: true
Frequency: 300
Timeout: 120
Kind: 'ping'
RetryEnabled: true
Locations: [
{
Id: 'us-va-ash-azr'
}
{
Id: 'emea-nl-ams-azr'
}
{
Id: 'apac-jp-kaw-edge'
}
]
Configuration: {
WebTest: '<WebTest Name="${pingTestName}" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="120" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile="" ResultsLocale=""> <Items> <Request Method="GET" Version="1.1" Url="${pingURL}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="200" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" /> </Items> <ValidationRules> <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExecutionOrder="BeforeDependents"> <RuleParameters> <RuleParameter Name="FindText" Value="${pingText}" /> <RuleParameter Name="IgnoreCase" Value="False" /> <RuleParameter Name="UseRegularExpression" Value="False" /> <RuleParameter Name="PassIfTextFound" Value="True" /> </RuleParameters> </ValidationRule> </ValidationRules> </WebTest>'
}
SyntheticMonitorId: pingTestName
}
}
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: pingAlertRuleName
location: 'global'
tags: {
'hidden-link:${resourceId('Microsoft.Insights/components', appName)}': 'Resource'
'hidden-link:${pingTest.id}': 'Resource'
}
properties: {
description: 'Alert for web test'
severity: 1
enabled: true
scopes: [
pingTest.id
resourceId('Microsoft.Insights/components', appName)
]
evaluationFrequency: 'PT1M'
windowSize: 'PT5M'
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria'
webTestId: pingTest.id
componentId: resourceId('Microsoft.Insights/components', appName)
failedLocationCount: 2
}
actions: [
{
actionGroupId: actionGroupId
}
]
}
}
Parameterbestand
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"value": "Replace with your Application Insights resource name"
},
"pingURL": {
"value": "https://www.yoursite.com"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resourceGroup-name/providers/microsoft.insights/actiongroups/replace-with-action-group-name"
},
"location": {
"value": "Replace with the location of your Application Insights resource"
},
"pingText": {
"defaultValue": "Optional parameter that allows you to perform a content-match for the presence of a specific string within the content returned from a pingURL response",
"type": "String"
},
}
}
Aanvullende configuratie van de pingText
-parameter voor de inhoudsovereenkomst wordt beheerd in het gedeelte Configuration/Webtest
van het sjabloonbestand. Met name de sectie hieronder:
<RuleParameter Name=\"FindText\" Value=\"',parameters('pingText'), '\" />
<RuleParameter Name=\"IgnoreCase\" Value=\"False\" />
<RuleParameter Name=\"UseRegularExpression\" Value=\"False\" />
<RuleParameter Name=\"PassIfTextFound\" Value=\"True\" />
Testlocaties
ID | Regio |
---|---|
emea-nl-ams-azr |
Europa -west |
us-ca-sjc-azr |
VS - west |
emea-ru-msa-edge |
Verenigd Koninkrijk Zuid |
emea-se-sto-edge |
Verenigd Koninkrijk West |
apac-sg-sin-azr |
Azië - zuidoost |
us-tx-sn1-azr |
VS - zuid-centraal |
us-il-ch1-azr |
VS - noord-centraal |
emea-gb-db3-azr |
Europa - noord |
apac-jp-kaw-edge |
Japan East |
emea-fr-pra-edge |
Frankrijk - centraal |
emea-ch-zrh-edge |
Frankrijk - zuid |
us-va-ash-azr |
VS - oost |
apac-hk-hkn-azr |
Azië - oost |
us-fl-mia-edge |
Central US |
latam-br-gru-edge |
Brazilië - zuid |
emea-au-syd-edge |
Australië - oost |
Testlocatie van de Amerikaanse overheid
ID | Regio |
---|---|
usgov-va-azr |
USGov Virginia |
usgov-phx-azr |
USGov Arizona |
usgov-tx-azr |
USGov Texas |
usgov-ddeast-azr |
USDoD East |
usgov-ddcentral-azr |
USDoD Central |