Azure Monitor의 메트릭 경고 규칙에 대한 Resource Manager 템플릿 샘플
이 문서에서는 Azure Resource Manager 템플릿을 사용하여 Azure Monitor에서 메트릭 경고 규칙을 구성하는 샘플을 제공합니다. 각 샘플에는 템플릿 파일과 템플릿에 제공할 샘플 값이 포함된 매개 변수 파일이 포함되어 있습니다.
참고 항목
사용 가능한 샘플 목록과 Azure 구독에 배포하는 방법에 대한 지침은 Azure Monitor에 대한 Azure Resource Manager 샘플을 참조하세요.
메트릭 경고 규칙에서 사용할 수 있는 리소스 목록은 Azure Monitor에서 메트릭 경고에 지원되는 리소스를 참조하세요. 경고 규칙에 대한 스키마 및 속성에 대한 설명은 메트릭 경고 - 만들기 또는 업데이트에서 사용할 수 있습니다.
참고 항목
리소스 형식에 대한 메트릭 경고를 만드는 리소스 템플릿: Azure Log Analytics 작업 영역(예를 들면) Microsoft.OperationalInsights/workspaces
에는 추가적인 단계가 필요합니다. 자세한 내용은 로그 메트릭 경고 - 리소스 템플릿을 참조하세요.
템플릿 참조
단일 조건, 정적 임계값
다음 샘플에서는 단일 조건과 정적 임계값을 사용하여 메트릭 경고 규칙을 만듭니다.
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
단일 조건, 동적 임계값
다음 샘플에서는 단일 조건과 동적 임계값을 사용하여 메트릭 경고 규칙을 만듭니다.
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
여러 조건, 정적 임계값
메트릭 경고는 다차원 메트릭에 대한 경고와 경고 규칙당 최대 5개의 조건을 지원합니다. 다음 샘플에서는 차원 메트릭에 대한 메트릭 경고 규칙을 만들고 여러 조건을 지정합니다.
여러 조건이 포함된 경고 규칙에서 차원을 사용하는 경우 적용되는 제약 조건은 다음과 같습니다.
각 조건 내에서 차원당 하나의 값만 선택할 수 있습니다.
"*"는 차원 값으로 사용할 수 없습니다.
다른 조건으로 구성된 메트릭에서 동일한 차원을 지원하는 경우 구성된 차원 값은 관련 조건의 모든 메트릭에 대해 동일한 방식으로 명시적으로 설정해야 합니다.
- 아래 예제에서는 Transactions 및 SuccessE2ELatency 메트릭 모두에 ApiName 차원이 있고 criterion1에서 ApiName 차원에 대해 "GetBlob" 값을 지정하고 있으므로 criterion2에서도 ApiName 차원에 대해 "GetBlob" 값을 설정해야 합니다.
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
여러 차원, 정적 임계값
단일 경고 규칙은 여러 메트릭 시계열을 한 번에 모니터링할 수 있으므로 관리할 경고 규칙이 줄어듭니다. 다음 샘플에서는 차원 메트릭에 대한 정적 메트릭 경고 규칙을 만듭니다.
이 샘플에서 경고 규칙은 Transactions 메트릭에 대한 ResponseType 및 ApiName 차원의 차원 값 조합을 모니터링합니다.
- ResponsType - "*" 와일드카드를 사용하면 미래 값을 포함하여 ResponseType 차원의 각 값에 대해 다른 시계열이 개별적으로 모니터링됩니다.
- ApiName - GetBlob 및 PutBlob 차원 값에 대해서만 다른 시계열이 모니터링됩니다.
예를 들어 이 경고 규칙으로 모니터링되는 몇 가지 잠재적인 시계열은 다음과 같습니다.
- 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
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
참고 항목
"모두"를 차원 값으로 사용하는 것은 "*"를 선택하는 것과 같습니다(모든 현재 및 미래 값).
여러 차원, 동적 임계값
단일 동적 임계값 경고 규칙은 수백 가지 메트릭 시계열(다양한 형식의 경우에도)에 대한 맞춤형 임계값을 한 번에 만들 수 있으므로 관리할 경고 규칙이 줄어듭니다. 다음 샘플에서는 차원 메트릭에 대한 동적 임계값 메트릭 경고 규칙을 만듭니다.
이 샘플에서 경고 규칙은 Transactions 메트릭에 대한 ResponseType 및 ApiName 차원의 차원 값 조합을 모니터링합니다.
- ResponsType - 미래 값을 포함하여 ResponseType 차원의 각 값에 대해 다른 시계열이 개별적으로 모니터링됩니다.
- ApiName - GetBlob 및 PutBlob 차원 값에 대해서만 다른 시계열이 모니터링됩니다.
예를 들어 이 경고 규칙으로 모니터링되는 몇 가지 잠재적인 시계열은 다음과 같습니다.
- 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
참고 항목
동적 임계값을 사용하는 메트릭 경고 규칙에는 현재 여러 조건이 지원되지 않습니다.
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
사용자 지정 메트릭, 정적 임계값
다음 템플릿을 사용하여 사용자 지정 메트릭에 대한 고급 정적 임계값 메트릭 경고 규칙을 만들 수 있습니다.
Azure Monitor의 사용자 지정 메트릭에 대한 자세한 내용은 Azure Monitor의 사용자 지정 메트릭을 참조하세요.
사용자 지정 메트릭에 대한 경고 규칙을 만드는 경우 메트릭 이름과 메트릭 네임스페이스를 모두 지정해야 합니다. 또한 아직 존재하지 않는 사용자 지정 메트릭에 대한 경고 규칙을 만들 수 없으므로 사용자 지정 메트릭이 이미 보고되고 있는지 확인해야 합니다.
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
참고 항목
Azure Portal을 통해 사용자 지정 메트릭을 검색하여 특정 사용자 지정 메트릭의 메트릭 네임스페이스를 찾을 수 있습니다.
여러 리소스
Azure Monitor는 동일한 Azure 지역에 있는 리소스에 대해 단일 메트릭 경고 규칙을 사용하여 동일한 종류의 여러 리소스를 모니터링할 수 있도록 지원합니다. 이 기능은 현재 Azure 퍼블릭 클라우드에서만 지원되고 가상 머신, SQL Server 데이터베이스, SQL Server 탄력적 풀, Azure Stack Edge 디바이스에 대해서만 지원됩니다. 또한 이 기능은 플랫폼 메트릭에만 사용할 수 있으며, 사용자 지정 메트릭에는 지원되지 않습니다.
동적 임계값 경고 규칙은 수백 가지 메트릭 시리즈에 대한 맞춤형 임계값(심지어 다양한 형식의)을 한 번에 만드는 데 유용할 수 있습니다. 그러면 관리할 경고 규칙이 더 적어집니다.
이 섹션에서는 단일 규칙으로 여러 리소스를 모니터링하는 다음 세 가지 시나리오를 위한 Azure Resource Manager 템플릿을 설명합니다.
- 하나 이상의 리소스 그룹에 있는 모든 가상 머신(한 Azure 지역에 있는) 모니터링
- 구독의 모든 가상 머신(한 Azure 지역 내) 모니터링
- 구독의 모든 가상 머신(한 Azure 지역 내) 목록 모니터링
참고 항목
- 여러 리소스를 모니터링하는 메트릭 경고 규칙에서는 하나의 조건만 허용됩니다.
- 단일 리소스에 대한 메트릭 경고를 만드는 경우 템플릿은 대상 리소스의
ResourceId
를 사용합니다. 여러 리소스에 대한 메트릭 경고를 만드는 경우 템플릿은 대상 리소스에 대해scope
,TargetResourceType
및TargetResourceRegion
을 사용합니다.
하나 이상의 리소스 그룹에 있는 모든 가상 머신에 대한 정적 임계값 경고
이 템플릿은 하나 이상의 리소스 그룹에 있는 모든 가상 머신(한 Azure 지역에 있는)의 CPU 백분율을 모니터링하는 정적 임계값 메트릭 경고 규칙을 만듭니다.
이 연습의 목적을 위해 아래의 json을 all-vms-in-resource-group-static.json으로 저장합니다.
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
하나 이상의 리소스 그룹에 있는 모든 가상 머신에 대한 동적 임계값 경고
이 샘플은 하나 이상의 리소스 그룹에서 한 Azure 지역 내에 있는 모든 가상 머신에 대한 CPU 백분율을 모니터링하는 동적 임계값 메트릭 경고 규칙을 만듭니다.
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
구독에 있는 모든 가상 머신에 대한 정적 임계값 경고
이 샘플은 구독에서 한 Azure 지역 내에 있는 모든 가상 머신에 대한 CPU 백분율을 모니터링하는 정적 임계값 메트릭 경고 규칙을 만듭니다.
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
구독에 있는 모든 가상 머신에 대한 동적 임계값 경고
이 샘플은 구독에서 한 Azure 지역 내에 있는 모든 가상 머신에 대한 CPU 백분율을 모니터링하는 동적 임계값 메트릭 경고 규칙을 만듭니다.
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
가상 머신의 목록에서 정적 임계값 경고
이 샘플은 구독에서 한 Azure 지역 내에 있는 모든 가상 머신의 목록에 대한 CPU 백분율을 모니터링하는 정적 임계값 메트릭 경고 규칙을 만듭니다.
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
가상 머신의 목록에 대한 동적 임계값 경고
이 샘플은 구독에서 한 Azure 지역 내에 있는 모든 가상 머신의 목록에 대한 CPU 백분율을 모니터링하는 동적 임계값 메트릭 경고 규칙을 만듭니다.
템플릿 파일
@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
}
]
}
}
매개 변수 파일
{
"$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"
}
}
}
메트릭 경고를 사용하여 가용성 테스트
Application Insights 가용성 테스트는 전 세계 다양한 위치에서 웹 사이트/애플리케이션의 가용성을 모니터링하는 데 도움이 됩니다. 가용성 테스트 경고는 특정 수의 위치에서 가용성 테스트가 실패할 때 사용자에게 알려줍니다. 메트릭 경고(Microsoft.Insights/metricAlerts)와 동일한 리소스 종류의 가용성 테스트 경고입니다. 다음 샘플에서는 간단한 가용성 테스트 및 관련 경고를 만듭니다.
참고 항목
&
;는 &에 대한 HTML 엔터티 참조입니다. URL 매개 변수는 여전히 단일 &로 구분되지만, HTML에서 URL을 언급하는 경우 인코딩해야 합니다. 따라서 pingURL 매개 변수 값에 "&"가 있으면 "&
;"를 사용하여 이스케이프해야 합니다.
템플릿 파일
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
}
]
}
}
매개 변수 파일
{
"$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"
},
}
}
내용 일치 pingText
매개 변수의 추가 구성은 템플릿 파일의 Configuration/Webtest
부분에서 제어됩니다. 구체적으로 아래 섹션을 참조하세요.
<RuleParameter Name=\"FindText\" Value=\"',parameters('pingText'), '\" />
<RuleParameter Name=\"IgnoreCase\" Value=\"False\" />
<RuleParameter Name=\"UseRegularExpression\" Value=\"False\" />
<RuleParameter Name=\"PassIfTextFound\" Value=\"True\" />
테스트 위치
ID | 지역 |
---|---|
emea-nl-ams-azr |
서유럽 |
us-ca-sjc-azr |
미국 서부 |
emea-ru-msa-edge |
영국 남부 |
emea-se-sto-edge |
영국 서부 |
apac-sg-sin-azr |
동남아시아 |
us-tx-sn1-azr |
미국 중남부 |
us-il-ch1-azr |
미국 중북부 |
emea-gb-db3-azr |
북유럽 |
apac-jp-kaw-edge |
일본 동부 |
emea-fr-pra-edge |
프랑스 중부 |
emea-ch-zrh-edge |
프랑스 남부 |
us-va-ash-azr |
미국 동부 |
apac-hk-hkn-azr |
동아시아 |
us-fl-mia-edge |
미국 중부 |
latam-br-gru-edge |
브라질 남부 |
emea-au-syd-edge |
오스트레일리아 동부 |
미국 정부 테스트 위치
ID | 지역 |
---|---|
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 |