Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Microsoft.Insights metricAlerts
Remarks
For guidance on deploying monitoring solutions, see Create monitoring resources by using Bicep.
Bicep resource definition
The metricAlerts resource type can be deployed with operations that target:
- Resource groups - See resource group deployment commands
For a list of changed properties in each API version, see change log.
Resource format
To create a Microsoft.Insights/metricAlerts resource, add the following Bicep to your template.
resource symbolicname 'Microsoft.Insights/metricAlerts@2024-03-01-preview' = {
identity: {
type: 'string'
userAssignedIdentities: {
{customized property}: {}
}
}
location: 'string'
name: 'string'
properties: {
actionProperties: {
{customized property}: 'string'
}
actions: [
{
actionGroupId: 'string'
webHookProperties: {
{customized property}: 'string'
}
}
]
autoMitigate: bool
criteria: {
odata.type: 'string'
// For remaining properties, see MetricAlertCriteria objects
}
customProperties: {
{customized property}: 'string'
}
description: 'string'
enabled: bool
evaluationFrequency: 'string'
resolveConfiguration: {
autoResolved: bool
timeToResolve: 'string'
}
scopes: [
'string'
]
severity: int
targetResourceRegion: 'string'
targetResourceType: 'string'
windowSize: 'string'
}
tags: {
{customized property}: 'string'
}
}
MultiPromQLCriteria objects
Set the criterionType property to specify the type of object.
For DynamicThresholdCriterion, use:
{
alertSensitivity: 'string'
criterionType: 'DynamicThresholdCriterion'
ignoreDataBefore: 'string'
operator: 'string'
}
For StaticThresholdCriterion, use:
{
criterionType: 'StaticThresholdCriterion'
}
MultiMetricCriteria objects
Set the criterionType property to specify the type of object.
For DynamicThresholdCriterion, use:
{
alertSensitivity: 'string'
criterionType: 'DynamicThresholdCriterion'
failingPeriods: {
minFailingPeriodsToAlert: int
numberOfEvaluationPeriods: int
}
ignoreDataBefore: 'string'
operator: 'string'
}
For StaticThresholdCriterion, use:
{
criterionType: 'StaticThresholdCriterion'
operator: 'string'
threshold: int
}
MetricAlertCriteria objects
Set the odata.type property to specify the type of object.
For Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria, use:
{
allOf: [
{
dimensions: [
{
name: 'string'
operator: 'string'
values: [
'string'
]
}
]
metricName: 'string'
metricNamespace: 'string'
name: 'string'
skipMetricValidation: bool
timeAggregation: 'string'
criterionType: 'string'
// For remaining properties, see MultiMetricCriteria objects
}
]
odata.type: 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria'
}
For Microsoft.Azure.Monitor.PromQLCriteria, use:
{
allOf: [
{
name: 'string'
query: 'string'
criterionType: 'string'
// For remaining properties, see MultiPromQLCriteria objects
}
]
failingPeriods: {
for: 'string'
}
odata.type: 'Microsoft.Azure.Monitor.PromQLCriteria'
}
For Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria, use:
{
allOf: [
{
criterionType: 'string'
dimensions: [
{
name: 'string'
operator: 'string'
values: [
'string'
]
}
]
metricName: 'string'
metricNamespace: 'string'
name: 'string'
operator: 'string'
skipMetricValidation: bool
threshold: int
timeAggregation: 'string'
}
]
odata.type: 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria'
}
For Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria, use:
{
componentId: 'string'
failedLocationCount: int
odata.type: 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria'
webTestId: 'string'
}
Property Values
Microsoft.Insights/metricAlerts
| Name | Description | Value |
|---|---|---|
| identity | The identity of the resource. | MicrosoftCommonIdentity |
| location | The geo-location where the resource lives | string (required) |
| name | The resource name | string (required) |
| properties | The alert rule properties of the resource. | MetricAlertProperties (required) |
| tags | Resource tags | Dictionary of tag names and values. See Tags in templates |
DynamicMetricCriteria
| Name | Description | Value |
|---|---|---|
| alertSensitivity | The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Previously undocumented values might be returned | 'High' 'Low' 'Medium' (required) |
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'DynamicThresholdCriterion' (required) |
| failingPeriods | The minimum number of violations required within the selected lookback time window required to raise an alert. | DynamicThresholdFailingPeriods (required) |
| ignoreDataBefore | Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) | string |
| operator | The operator used to compare the metric value against the threshold. Previously undocumented values might be returned | 'GreaterOrLessThan' 'GreaterThan' 'LessThan' (required) |
DynamicPromQLCriteria
| Name | Description | Value |
|---|---|---|
| alertSensitivity | The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Previously undocumented values might be returned | 'High' 'Low' 'Medium' (required) |
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'DynamicThresholdCriterion' (required) |
| ignoreDataBefore | Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) | string |
| operator | The operator used to compare the metric value against the threshold. Previously undocumented values might be returned | 'GreaterOrLessThan' 'GreaterThan' 'LessThan' (required) |
DynamicThresholdFailingPeriods
| Name | Description | Value |
|---|---|---|
| minFailingPeriodsToAlert | The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. | int (required) |
| numberOfEvaluationPeriods | The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. | int (required) |
MetricAlertAction
| Name | Description | Value |
|---|---|---|
| actionGroupId | The id of the action group to use. | string |
| webHookProperties | This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook. | MetricAlertActionWebHookProperties |
MetricAlertActionWebHookProperties
| Name | Description | Value |
|---|
MetricAlertCriteria
| Name | Description | Value |
|---|---|---|
| odata.type | Set to 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' for type MetricAlertMultipleResourceMultipleMetricCriteria. Set to 'Microsoft.Azure.Monitor.PromQLCriteria' for type PromQLCriteria. Set to 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' for type MetricAlertSingleResourceMultipleMetricCriteria. Set to 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' for type WebtestLocationAvailabilityCriteria. | 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' 'Microsoft.Azure.Monitor.PromQLCriteria' 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' (required) |
MetricAlertMultipleResourceMultipleMetricCriteria
| Name | Description | Value |
|---|---|---|
| allOf | The list of multiple metric criteria for this 'all of' operation. | MultiMetricCriteria[] |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' (required) |
MetricAlertProperties
| Name | Description | Value |
|---|---|---|
| actionProperties | The properties of an action properties. | MetricAlertPropertiesActionProperties |
| actions | The array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. | MetricAlertAction[] |
| autoMitigate | The flag that indicates whether the alert should be auto resolved or not. The default is true. | bool |
| criteria | Defines the specific alert criteria information. | MetricAlertCriteria (required) |
| customProperties | The properties of an alert payload. | MetricAlertPropertiesCustomProperties |
| description | The description of the metric alert that will be included in the alert email. | string |
| enabled | The flag that indicates whether the metric alert is enabled. | bool (required) |
| evaluationFrequency | How often the metric alert is evaluated represented in ISO 8601 duration format. | string (required) |
| resolveConfiguration | The configuration for how the alert is resolved. Applicable for PromQLCriteria. | ResolveConfiguration |
| scopes | The list of resource id's that this metric alert is scoped to. You cannot change the scope of a metric rule based on logs. | string[] (required) |
| severity | Alert severity {0, 1, 2, 3, 4} | int (required) |
| targetResourceRegion | The region of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. | string |
| targetResourceType | The resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. | string |
| windowSize | The period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. | string |
MetricAlertPropertiesActionProperties
| Name | Description | Value |
|---|
MetricAlertPropertiesCustomProperties
| Name | Description | Value |
|---|
MetricAlertSingleResourceMultipleMetricCriteria
| Name | Description | Value |
|---|---|---|
| allOf | The list of metric criteria for this 'all of' operation. | MetricCriteria[] |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' (required) |
MetricCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'DynamicThresholdCriterion' 'StaticThresholdCriterion' (required) |
| dimensions | List of dimension conditions. | MetricDimension[] |
| metricName | Name of the metric. | string (required) |
| metricNamespace | Namespace of the metric. | string |
| name | Name of the criteria. | string (required) |
| operator | The criteria operator. Previously undocumented values might be returned | 'Equals' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' (required) |
| skipMetricValidation | Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. | bool |
| threshold | The criteria threshold value that activates the alert. | int (required) |
| timeAggregation | The criteria time aggregation types. Previously undocumented values might be returned | 'Average' 'Count' 'Maximum' 'Minimum' 'Total' (required) |
MetricCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'StaticThresholdCriterion' (required) |
| operator | The criteria operator. Previously undocumented values might be returned | 'Equals' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' (required) |
| threshold | The criteria threshold value that activates the alert. | int (required) |
MetricDimension
| Name | Description | Value |
|---|---|---|
| name | Name of the dimension. | string (required) |
| operator | The dimension operator. Only 'Include' and 'Exclude' are supported | string (required) |
| values | List of dimension values. | string[] (required) |
MicrosoftCommonIdentity
| Name | Description | Value |
|---|---|---|
| type | Type of managed service identity. | 'None' 'SystemAssigned' 'UserAssigned' (required) |
| userAssignedIdentities | The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. | MicrosoftCommonIdentityUserAssignedIdentities |
MicrosoftCommonIdentityUserAssignedIdentities
| Name | Description | Value |
|---|
MicrosoftCommonUserIdentityProperties
| Name | Description | Value |
|---|
MultiMetricCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Set to 'DynamicThresholdCriterion' for type DynamicMetricCriteria. Set to 'StaticThresholdCriterion' for type MetricCriteria. | 'DynamicThresholdCriterion' 'StaticThresholdCriterion' (required) |
| dimensions | List of dimension conditions. | MetricDimension[] |
| metricName | Name of the metric. | string (required) |
| metricNamespace | Namespace of the metric. | string |
| name | Name of the criteria. | string (required) |
| skipMetricValidation | Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. | bool |
| timeAggregation | The criteria time aggregation types. Previously undocumented values might be returned | 'Average' 'Count' 'Maximum' 'Minimum' 'Total' (required) |
MultiPromQLCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Set to 'DynamicThresholdCriterion' for type DynamicPromQLCriteria. Set to 'StaticThresholdCriterion' for type StaticPromQLCriteria. | 'DynamicThresholdCriterion' 'StaticThresholdCriterion' (required) |
| name | Name of the criteria. | string (required) |
| query | The query used to evaluate the alert rule | string (required) |
PromQLCriteria
| Name | Description | Value |
|---|---|---|
| allOf | The list of promQL criteria. Alert will be raised when all conditions are met. | MultiPromQLCriteria[] |
| failingPeriods | Configuration for failing periods in query-based alerts. | QueryFailingPeriods |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.PromQLCriteria' (required) |
QueryFailingPeriods
| Name | Description | Value |
|---|---|---|
| for | The amount of time (in ISO 8601 duration format) alert must be active before firing. | string (required) |
ResolveConfiguration
| Name | Description | Value |
|---|---|---|
| autoResolved | Indicates whether the alert should be auto resolved | bool (required) |
| timeToResolve | The time (in ISO 8601 duration format) after which the alert should be auto resolved | string |
StaticPromQLCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'StaticThresholdCriterion' (required) |
TrackedResourceTags
| Name | Description | Value |
|---|
WebtestLocationAvailabilityCriteria
| Name | Description | Value |
|---|---|---|
| componentId | The Application Insights resource Id. | string (required) |
| failedLocationCount | The number of failed locations. | int (required) |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' (required) |
| webTestId | The Application Insights web test Id. | string (required) |
Usage Examples
Bicep Samples
A basic example of deploying Metric Alert within Azure Monitor.
param resourceName string = 'acctest0001'
param location string = 'westeurope'
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: resourceName
location: 'global'
properties: {
actions: []
autoMitigate: true
criteria: {
allOf: [
{
criterionType: 'StaticThresholdCriterion'
dimensions: []
metricName: 'UsedCapacity'
metricNamespace: 'Microsoft.Storage/storageAccounts'
name: 'Metric1'
operator: 'GreaterThan'
skipMetricValidation: false
threshold: any('55.5')
timeAggregation: 'Average'
}
]
'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria'
}
description: ''
enabled: true
evaluationFrequency: 'PT1M'
scopes: [
storageAccount.id
]
severity: 3
targetResourceRegion: ''
targetResourceType: ''
windowSize: 'PT1H'
}
tags: {
CUSTOMER: 'CUSTOMERx'
Example: 'Example123'
terraform: 'Coolllll'
test: '123'
}
}
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = {
name: resourceName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
allowBlobPublicAccess: true
allowCrossTenantReplication: true
allowSharedKeyAccess: true
defaultToOAuthAuthentication: false
encryption: {
keySource: 'Microsoft.Storage'
services: {
queue: {
keyType: 'Service'
}
table: {
keyType: 'Service'
}
}
}
isHnsEnabled: false
isNfsV3Enabled: false
isSftpEnabled: false
minimumTlsVersion: 'TLS1_2'
networkAcls: {
defaultAction: 'Allow'
}
publicNetworkAccess: 'Enabled'
supportsHttpsTrafficOnly: true
}
}
Azure Verified Modules
The following Azure Verified Modules can be used to deploy this resource type.
| Module | Description |
|---|---|
| Metric Alert | AVM Resource Module for Metric Alert |
Azure Quickstart Samples
The following Azure Quickstart templates contain Bicep samples for deploying this resource type.
| Bicep File | Description |
|---|---|
| Deploy Application Insight and create alert in it | This template allows you to deploy Application Insight and create alert in it |
ARM template resource definition
The metricAlerts resource type can be deployed with operations that target:
- Resource groups - See resource group deployment commands
For a list of changed properties in each API version, see change log.
Resource format
To create a Microsoft.Insights/metricAlerts resource, add the following JSON to your template.
{
"type": "Microsoft.Insights/metricAlerts",
"apiVersion": "2024-03-01-preview",
"name": "string",
"identity": {
"type": "string",
"userAssignedIdentities": {
"{customized property}": {
}
}
},
"location": "string",
"properties": {
"actionProperties": {
"{customized property}": "string"
},
"actions": [
{
"actionGroupId": "string",
"webHookProperties": {
"{customized property}": "string"
}
}
],
"autoMitigate": "bool",
"criteria": {
"odata.type": "string"
// For remaining properties, see MetricAlertCriteria objects
},
"customProperties": {
"{customized property}": "string"
},
"description": "string",
"enabled": "bool",
"evaluationFrequency": "string",
"resolveConfiguration": {
"autoResolved": "bool",
"timeToResolve": "string"
},
"scopes": [ "string" ],
"severity": "int",
"targetResourceRegion": "string",
"targetResourceType": "string",
"windowSize": "string"
},
"tags": {
"{customized property}": "string"
}
}
MultiPromQLCriteria objects
Set the criterionType property to specify the type of object.
For DynamicThresholdCriterion, use:
{
"alertSensitivity": "string",
"criterionType": "DynamicThresholdCriterion",
"ignoreDataBefore": "string",
"operator": "string"
}
For StaticThresholdCriterion, use:
{
"criterionType": "StaticThresholdCriterion"
}
MultiMetricCriteria objects
Set the criterionType property to specify the type of object.
For DynamicThresholdCriterion, use:
{
"alertSensitivity": "string",
"criterionType": "DynamicThresholdCriterion",
"failingPeriods": {
"minFailingPeriodsToAlert": "int",
"numberOfEvaluationPeriods": "int"
},
"ignoreDataBefore": "string",
"operator": "string"
}
For StaticThresholdCriterion, use:
{
"criterionType": "StaticThresholdCriterion",
"operator": "string",
"threshold": "int"
}
MetricAlertCriteria objects
Set the odata.type property to specify the type of object.
For Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria, use:
{
"allOf": [ {
"dimensions": [
{
"name": "string",
"operator": "string",
"values": [ "string" ]
}
],
"metricName": "string",
"metricNamespace": "string",
"name": "string",
"skipMetricValidation": "bool",
"timeAggregation": "string",
"criterionType": "string"
// For remaining properties, see MultiMetricCriteria objects
} ],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
}
For Microsoft.Azure.Monitor.PromQLCriteria, use:
{
"allOf": [ {
"name": "string",
"query": "string",
"criterionType": "string"
// For remaining properties, see MultiPromQLCriteria objects
} ],
"failingPeriods": {
"for": "string"
},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria"
}
For Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria, use:
{
"allOf": [
{
"criterionType": "string",
"dimensions": [
{
"name": "string",
"operator": "string",
"values": [ "string" ]
}
],
"metricName": "string",
"metricNamespace": "string",
"name": "string",
"operator": "string",
"skipMetricValidation": "bool",
"threshold": "int",
"timeAggregation": "string"
}
],
"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"
}
For Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria, use:
{
"componentId": "string",
"failedLocationCount": "int",
"odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria",
"webTestId": "string"
}
Property Values
Microsoft.Insights/metricAlerts
| Name | Description | Value |
|---|---|---|
| apiVersion | The api version | '2024-03-01-preview' |
| identity | The identity of the resource. | MicrosoftCommonIdentity |
| location | The geo-location where the resource lives | string (required) |
| name | The resource name | string (required) |
| properties | The alert rule properties of the resource. | MetricAlertProperties (required) |
| tags | Resource tags | Dictionary of tag names and values. See Tags in templates |
| type | The resource type | 'Microsoft.Insights/metricAlerts' |
DynamicMetricCriteria
| Name | Description | Value |
|---|---|---|
| alertSensitivity | The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Previously undocumented values might be returned | 'High' 'Low' 'Medium' (required) |
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'DynamicThresholdCriterion' (required) |
| failingPeriods | The minimum number of violations required within the selected lookback time window required to raise an alert. | DynamicThresholdFailingPeriods (required) |
| ignoreDataBefore | Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) | string |
| operator | The operator used to compare the metric value against the threshold. Previously undocumented values might be returned | 'GreaterOrLessThan' 'GreaterThan' 'LessThan' (required) |
DynamicPromQLCriteria
| Name | Description | Value |
|---|---|---|
| alertSensitivity | The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Previously undocumented values might be returned | 'High' 'Low' 'Medium' (required) |
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'DynamicThresholdCriterion' (required) |
| ignoreDataBefore | Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) | string |
| operator | The operator used to compare the metric value against the threshold. Previously undocumented values might be returned | 'GreaterOrLessThan' 'GreaterThan' 'LessThan' (required) |
DynamicThresholdFailingPeriods
| Name | Description | Value |
|---|---|---|
| minFailingPeriodsToAlert | The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. | int (required) |
| numberOfEvaluationPeriods | The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. | int (required) |
MetricAlertAction
| Name | Description | Value |
|---|---|---|
| actionGroupId | The id of the action group to use. | string |
| webHookProperties | This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook. | MetricAlertActionWebHookProperties |
MetricAlertActionWebHookProperties
| Name | Description | Value |
|---|
MetricAlertCriteria
| Name | Description | Value |
|---|---|---|
| odata.type | Set to 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' for type MetricAlertMultipleResourceMultipleMetricCriteria. Set to 'Microsoft.Azure.Monitor.PromQLCriteria' for type PromQLCriteria. Set to 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' for type MetricAlertSingleResourceMultipleMetricCriteria. Set to 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' for type WebtestLocationAvailabilityCriteria. | 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' 'Microsoft.Azure.Monitor.PromQLCriteria' 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' (required) |
MetricAlertMultipleResourceMultipleMetricCriteria
| Name | Description | Value |
|---|---|---|
| allOf | The list of multiple metric criteria for this 'all of' operation. | MultiMetricCriteria[] |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' (required) |
MetricAlertProperties
| Name | Description | Value |
|---|---|---|
| actionProperties | The properties of an action properties. | MetricAlertPropertiesActionProperties |
| actions | The array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. | MetricAlertAction[] |
| autoMitigate | The flag that indicates whether the alert should be auto resolved or not. The default is true. | bool |
| criteria | Defines the specific alert criteria information. | MetricAlertCriteria (required) |
| customProperties | The properties of an alert payload. | MetricAlertPropertiesCustomProperties |
| description | The description of the metric alert that will be included in the alert email. | string |
| enabled | The flag that indicates whether the metric alert is enabled. | bool (required) |
| evaluationFrequency | How often the metric alert is evaluated represented in ISO 8601 duration format. | string (required) |
| resolveConfiguration | The configuration for how the alert is resolved. Applicable for PromQLCriteria. | ResolveConfiguration |
| scopes | The list of resource id's that this metric alert is scoped to. You cannot change the scope of a metric rule based on logs. | string[] (required) |
| severity | Alert severity {0, 1, 2, 3, 4} | int (required) |
| targetResourceRegion | The region of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. | string |
| targetResourceType | The resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. | string |
| windowSize | The period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. | string |
MetricAlertPropertiesActionProperties
| Name | Description | Value |
|---|
MetricAlertPropertiesCustomProperties
| Name | Description | Value |
|---|
MetricAlertSingleResourceMultipleMetricCriteria
| Name | Description | Value |
|---|---|---|
| allOf | The list of metric criteria for this 'all of' operation. | MetricCriteria[] |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' (required) |
MetricCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'DynamicThresholdCriterion' 'StaticThresholdCriterion' (required) |
| dimensions | List of dimension conditions. | MetricDimension[] |
| metricName | Name of the metric. | string (required) |
| metricNamespace | Namespace of the metric. | string |
| name | Name of the criteria. | string (required) |
| operator | The criteria operator. Previously undocumented values might be returned | 'Equals' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' (required) |
| skipMetricValidation | Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. | bool |
| threshold | The criteria threshold value that activates the alert. | int (required) |
| timeAggregation | The criteria time aggregation types. Previously undocumented values might be returned | 'Average' 'Count' 'Maximum' 'Minimum' 'Total' (required) |
MetricCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'StaticThresholdCriterion' (required) |
| operator | The criteria operator. Previously undocumented values might be returned | 'Equals' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' (required) |
| threshold | The criteria threshold value that activates the alert. | int (required) |
MetricDimension
| Name | Description | Value |
|---|---|---|
| name | Name of the dimension. | string (required) |
| operator | The dimension operator. Only 'Include' and 'Exclude' are supported | string (required) |
| values | List of dimension values. | string[] (required) |
MicrosoftCommonIdentity
| Name | Description | Value |
|---|---|---|
| type | Type of managed service identity. | 'None' 'SystemAssigned' 'UserAssigned' (required) |
| userAssignedIdentities | The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. | MicrosoftCommonIdentityUserAssignedIdentities |
MicrosoftCommonIdentityUserAssignedIdentities
| Name | Description | Value |
|---|
MicrosoftCommonUserIdentityProperties
| Name | Description | Value |
|---|
MultiMetricCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Set to 'DynamicThresholdCriterion' for type DynamicMetricCriteria. Set to 'StaticThresholdCriterion' for type MetricCriteria. | 'DynamicThresholdCriterion' 'StaticThresholdCriterion' (required) |
| dimensions | List of dimension conditions. | MetricDimension[] |
| metricName | Name of the metric. | string (required) |
| metricNamespace | Namespace of the metric. | string |
| name | Name of the criteria. | string (required) |
| skipMetricValidation | Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. | bool |
| timeAggregation | The criteria time aggregation types. Previously undocumented values might be returned | 'Average' 'Count' 'Maximum' 'Minimum' 'Total' (required) |
MultiPromQLCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Set to 'DynamicThresholdCriterion' for type DynamicPromQLCriteria. Set to 'StaticThresholdCriterion' for type StaticPromQLCriteria. | 'DynamicThresholdCriterion' 'StaticThresholdCriterion' (required) |
| name | Name of the criteria. | string (required) |
| query | The query used to evaluate the alert rule | string (required) |
PromQLCriteria
| Name | Description | Value |
|---|---|---|
| allOf | The list of promQL criteria. Alert will be raised when all conditions are met. | MultiPromQLCriteria[] |
| failingPeriods | Configuration for failing periods in query-based alerts. | QueryFailingPeriods |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.PromQLCriteria' (required) |
QueryFailingPeriods
| Name | Description | Value |
|---|---|---|
| for | The amount of time (in ISO 8601 duration format) alert must be active before firing. | string (required) |
ResolveConfiguration
| Name | Description | Value |
|---|---|---|
| autoResolved | Indicates whether the alert should be auto resolved | bool (required) |
| timeToResolve | The time (in ISO 8601 duration format) after which the alert should be auto resolved | string |
StaticPromQLCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'StaticThresholdCriterion' (required) |
TrackedResourceTags
| Name | Description | Value |
|---|
WebtestLocationAvailabilityCriteria
| Name | Description | Value |
|---|---|---|
| componentId | The Application Insights resource Id. | string (required) |
| failedLocationCount | The number of failed locations. | int (required) |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' (required) |
| webTestId | The Application Insights web test Id. | string (required) |
Usage Examples
Azure Quickstart Templates
The following Azure Quickstart templates deploy this resource type.
| Template | Description |
|---|---|
| Alert for Backend Last Byte Response metric 👁 Deploy to Azure |
Use such templates to easily create some important event alerts for your Azure Application Gateway. |
| Alert for Unhealthy Host Count metric 👁 Deploy to Azure |
Use such templates to easily create some important event alerts for your Azure Application Gateway. |
| BrowserBox Azure Edition 👁 Deploy to Azure |
This template deploys BrowserBox on an Azure Ubuntu Server 22.04 LTS, Debian 11, or RHEL 8.7 LVM VM. |
| Create alerts for your Application Gateway 👁 Deploy to Azure |
Use these templates to easily create some important event alerts for your Azure Application Gateway. |
| Deploy Application Insight and create alert in it 👁 Deploy to Azure |
This template allows you to deploy Application Insight and create alert in it |
| Dynamic Web Test Creation 👁 Deploy to Azure |
Create any number of App Insights web (ping) tests. |
| Enterprise Governance-AppService, SQL DB, AD, OMS, Runbooks 👁 Deploy to Azure |
Cloud adoption for an Enterprise, small or large, require responsible and efficient governance models to derive value from their cloud deployments. CloudWise (a code-name for the solution), is a composite solution available from Azure Partner QuickStarts, is an adoption enabler for Customers, System Integrators and Partners alike, that delivers a self-serviceable, automated governance and operations solution, focused on Optimizing Your Costs, Improve Your Application(s) Reliability, Reducing Business Risk. The solution highlights the core governance pillars of Visibility and Control. |
| Metric alert rule for an availability test 👁 Deploy to Azure |
This template creates an Application Insights availability test along with a metric alert rule that monitors it. |
| Metric alert rule with a dynamic threshold 👁 Deploy to Azure |
This template creates a metric alert rule that monitors the CPU Percentage metric of a virtual machine using a dynamic threshold condition type. |
| Metric alert rule with a static threshold 👁 Deploy to Azure |
This template creates a metric alert rule that monitors the CPU Percentage metric of a virtual machine using a static threshold condition type. |
| Scalable Umbraco CMS Web App 👁 Deploy to Azure |
This template provides a easy way to deploy umbraco CMS web app on Azure App Service Web Apps. |
Terraform (AzAPI provider) resource definition
The metricAlerts resource type can be deployed with operations that target:
- Resource groups
For a list of changed properties in each API version, see change log.
Resource format
To create a Microsoft.Insights/metricAlerts resource, add the following Terraform to your template.
resource "azapi_resource" "symbolicname" {
type = "Microsoft.Insights/metricAlerts@2024-03-01-preview"
name = "string"
parent_id = "string"
identity {
type = "string"
identity_ids = [
"string"
]
}
location = "string"
tags = {
{customized property} = "string"
}
body = {
properties = {
actionProperties = {
{customized property} = "string"
}
actions = [
{
actionGroupId = "string"
webHookProperties = {
{customized property} = "string"
}
}
]
autoMitigate = bool
criteria = {
odata.type = "string"
// For remaining properties, see MetricAlertCriteria objects
}
customProperties = {
{customized property} = "string"
}
description = "string"
enabled = bool
evaluationFrequency = "string"
resolveConfiguration = {
autoResolved = bool
timeToResolve = "string"
}
scopes = [
"string"
]
severity = int
targetResourceRegion = "string"
targetResourceType = "string"
windowSize = "string"
}
}
}
MultiPromQLCriteria objects
Set the criterionType property to specify the type of object.
For DynamicThresholdCriterion, use:
{
alertSensitivity = "string"
criterionType = "DynamicThresholdCriterion"
ignoreDataBefore = "string"
operator = "string"
}
For StaticThresholdCriterion, use:
{
criterionType = "StaticThresholdCriterion"
}
MultiMetricCriteria objects
Set the criterionType property to specify the type of object.
For DynamicThresholdCriterion, use:
{
alertSensitivity = "string"
criterionType = "DynamicThresholdCriterion"
failingPeriods = {
minFailingPeriodsToAlert = int
numberOfEvaluationPeriods = int
}
ignoreDataBefore = "string"
operator = "string"
}
For StaticThresholdCriterion, use:
{
criterionType = "StaticThresholdCriterion"
operator = "string"
threshold = int
}
MetricAlertCriteria objects
Set the odata.type property to specify the type of object.
For Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria, use:
{
allOf = [
{
dimensions = [
{
name = "string"
operator = "string"
values = [
"string"
]
}
]
metricName = "string"
metricNamespace = "string"
name = "string"
skipMetricValidation = bool
timeAggregation = "string"
criterionType = "string"
// For remaining properties, see MultiMetricCriteria objects
}
]
odata.type = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
}
For Microsoft.Azure.Monitor.PromQLCriteria, use:
{
allOf = [
{
name = "string"
query = "string"
criterionType = "string"
// For remaining properties, see MultiPromQLCriteria objects
}
]
failingPeriods = {
for = "string"
}
odata.type = "Microsoft.Azure.Monitor.PromQLCriteria"
}
For Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria, use:
{
allOf = [
{
criterionType = "string"
dimensions = [
{
name = "string"
operator = "string"
values = [
"string"
]
}
]
metricName = "string"
metricNamespace = "string"
name = "string"
operator = "string"
skipMetricValidation = bool
threshold = int
timeAggregation = "string"
}
]
odata.type = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"
}
For Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria, use:
{
componentId = "string"
failedLocationCount = int
odata.type = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria"
webTestId = "string"
}
Property Values
Microsoft.Insights/metricAlerts
| Name | Description | Value |
|---|---|---|
| identity | The identity of the resource. | MicrosoftCommonIdentity |
| location | The geo-location where the resource lives | string (required) |
| name | The resource name | string (required) |
| properties | The alert rule properties of the resource. | MetricAlertProperties (required) |
| tags | Resource tags | Dictionary of tag names and values. |
| type | The resource type | "Microsoft.Insights/metricAlerts@2024-03-01-preview" |
DynamicMetricCriteria
| Name | Description | Value |
|---|---|---|
| alertSensitivity | The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Previously undocumented values might be returned | 'High' 'Low' 'Medium' (required) |
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'DynamicThresholdCriterion' (required) |
| failingPeriods | The minimum number of violations required within the selected lookback time window required to raise an alert. | DynamicThresholdFailingPeriods (required) |
| ignoreDataBefore | Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) | string |
| operator | The operator used to compare the metric value against the threshold. Previously undocumented values might be returned | 'GreaterOrLessThan' 'GreaterThan' 'LessThan' (required) |
DynamicPromQLCriteria
| Name | Description | Value |
|---|---|---|
| alertSensitivity | The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Previously undocumented values might be returned | 'High' 'Low' 'Medium' (required) |
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'DynamicThresholdCriterion' (required) |
| ignoreDataBefore | Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) | string |
| operator | The operator used to compare the metric value against the threshold. Previously undocumented values might be returned | 'GreaterOrLessThan' 'GreaterThan' 'LessThan' (required) |
DynamicThresholdFailingPeriods
| Name | Description | Value |
|---|---|---|
| minFailingPeriodsToAlert | The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. | int (required) |
| numberOfEvaluationPeriods | The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. | int (required) |
MetricAlertAction
| Name | Description | Value |
|---|---|---|
| actionGroupId | The id of the action group to use. | string |
| webHookProperties | This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook. | MetricAlertActionWebHookProperties |
MetricAlertActionWebHookProperties
| Name | Description | Value |
|---|
MetricAlertCriteria
| Name | Description | Value |
|---|---|---|
| odata.type | Set to 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' for type MetricAlertMultipleResourceMultipleMetricCriteria. Set to 'Microsoft.Azure.Monitor.PromQLCriteria' for type PromQLCriteria. Set to 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' for type MetricAlertSingleResourceMultipleMetricCriteria. Set to 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' for type WebtestLocationAvailabilityCriteria. | 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' 'Microsoft.Azure.Monitor.PromQLCriteria' 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' (required) |
MetricAlertMultipleResourceMultipleMetricCriteria
| Name | Description | Value |
|---|---|---|
| allOf | The list of multiple metric criteria for this 'all of' operation. | MultiMetricCriteria[] |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' (required) |
MetricAlertProperties
| Name | Description | Value |
|---|---|---|
| actionProperties | The properties of an action properties. | MetricAlertPropertiesActionProperties |
| actions | The array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. | MetricAlertAction[] |
| autoMitigate | The flag that indicates whether the alert should be auto resolved or not. The default is true. | bool |
| criteria | Defines the specific alert criteria information. | MetricAlertCriteria (required) |
| customProperties | The properties of an alert payload. | MetricAlertPropertiesCustomProperties |
| description | The description of the metric alert that will be included in the alert email. | string |
| enabled | The flag that indicates whether the metric alert is enabled. | bool (required) |
| evaluationFrequency | How often the metric alert is evaluated represented in ISO 8601 duration format. | string (required) |
| resolveConfiguration | The configuration for how the alert is resolved. Applicable for PromQLCriteria. | ResolveConfiguration |
| scopes | The list of resource id's that this metric alert is scoped to. You cannot change the scope of a metric rule based on logs. | string[] (required) |
| severity | Alert severity {0, 1, 2, 3, 4} | int (required) |
| targetResourceRegion | The region of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. | string |
| targetResourceType | The resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. | string |
| windowSize | The period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. | string |
MetricAlertPropertiesActionProperties
| Name | Description | Value |
|---|
MetricAlertPropertiesCustomProperties
| Name | Description | Value |
|---|
MetricAlertSingleResourceMultipleMetricCriteria
| Name | Description | Value |
|---|---|---|
| allOf | The list of metric criteria for this 'all of' operation. | MetricCriteria[] |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' (required) |
MetricCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'DynamicThresholdCriterion' 'StaticThresholdCriterion' (required) |
| dimensions | List of dimension conditions. | MetricDimension[] |
| metricName | Name of the metric. | string (required) |
| metricNamespace | Namespace of the metric. | string |
| name | Name of the criteria. | string (required) |
| operator | The criteria operator. Previously undocumented values might be returned | 'Equals' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' (required) |
| skipMetricValidation | Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. | bool |
| threshold | The criteria threshold value that activates the alert. | int (required) |
| timeAggregation | The criteria time aggregation types. Previously undocumented values might be returned | 'Average' 'Count' 'Maximum' 'Minimum' 'Total' (required) |
MetricCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'StaticThresholdCriterion' (required) |
| operator | The criteria operator. Previously undocumented values might be returned | 'Equals' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' (required) |
| threshold | The criteria threshold value that activates the alert. | int (required) |
MetricDimension
| Name | Description | Value |
|---|---|---|
| name | Name of the dimension. | string (required) |
| operator | The dimension operator. Only 'Include' and 'Exclude' are supported | string (required) |
| values | List of dimension values. | string[] (required) |
MicrosoftCommonIdentity
| Name | Description | Value |
|---|---|---|
| type | Type of managed service identity. | 'None' 'SystemAssigned' 'UserAssigned' (required) |
| userAssignedIdentities | The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. | MicrosoftCommonIdentityUserAssignedIdentities |
MicrosoftCommonIdentityUserAssignedIdentities
| Name | Description | Value |
|---|
MicrosoftCommonUserIdentityProperties
| Name | Description | Value |
|---|
MultiMetricCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Set to 'DynamicThresholdCriterion' for type DynamicMetricCriteria. Set to 'StaticThresholdCriterion' for type MetricCriteria. | 'DynamicThresholdCriterion' 'StaticThresholdCriterion' (required) |
| dimensions | List of dimension conditions. | MetricDimension[] |
| metricName | Name of the metric. | string (required) |
| metricNamespace | Namespace of the metric. | string |
| name | Name of the criteria. | string (required) |
| skipMetricValidation | Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. | bool |
| timeAggregation | The criteria time aggregation types. Previously undocumented values might be returned | 'Average' 'Count' 'Maximum' 'Minimum' 'Total' (required) |
MultiPromQLCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Set to 'DynamicThresholdCriterion' for type DynamicPromQLCriteria. Set to 'StaticThresholdCriterion' for type StaticPromQLCriteria. | 'DynamicThresholdCriterion' 'StaticThresholdCriterion' (required) |
| name | Name of the criteria. | string (required) |
| query | The query used to evaluate the alert rule | string (required) |
PromQLCriteria
| Name | Description | Value |
|---|---|---|
| allOf | The list of promQL criteria. Alert will be raised when all conditions are met. | MultiPromQLCriteria[] |
| failingPeriods | Configuration for failing periods in query-based alerts. | QueryFailingPeriods |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.PromQLCriteria' (required) |
QueryFailingPeriods
| Name | Description | Value |
|---|---|---|
| for | The amount of time (in ISO 8601 duration format) alert must be active before firing. | string (required) |
ResolveConfiguration
| Name | Description | Value |
|---|---|---|
| autoResolved | Indicates whether the alert should be auto resolved | bool (required) |
| timeToResolve | The time (in ISO 8601 duration format) after which the alert should be auto resolved | string |
StaticPromQLCriteria
| Name | Description | Value |
|---|---|---|
| criterionType | Specifies the type of threshold criteria. Previously undocumented values might be returned | 'StaticThresholdCriterion' (required) |
TrackedResourceTags
| Name | Description | Value |
|---|
WebtestLocationAvailabilityCriteria
| Name | Description | Value |
|---|---|---|
| componentId | The Application Insights resource Id. | string (required) |
| failedLocationCount | The number of failed locations. | int (required) |
| odata.type | Specifies the type of the alert criteria. Previously undocumented values might be returned | 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' (required) |
| webTestId | The Application Insights web test Id. | string (required) |
Usage Examples
Terraform Samples
A basic example of deploying Metric Alert within Azure Monitor.
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
}
}
provider "azapi" {
skip_provider_registration = false
}
variable "resource_name" {
type = string
default = "acctest0001"
}
variable "location" {
type = string
default = "westeurope"
}
resource "azapi_resource" "resourceGroup" {
type = "Microsoft.Resources/resourceGroups@2020-06-01"
name = var.resource_name
location = var.location
}
resource "azapi_resource" "storageAccount" {
type = "Microsoft.Storage/storageAccounts@2021-09-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = {
kind = "StorageV2"
properties = {
accessTier = "Hot"
allowBlobPublicAccess = true
allowCrossTenantReplication = true
allowSharedKeyAccess = true
defaultToOAuthAuthentication = false
encryption = {
keySource = "Microsoft.Storage"
services = {
queue = {
keyType = "Service"
}
table = {
keyType = "Service"
}
}
}
isHnsEnabled = false
isNfsV3Enabled = false
isSftpEnabled = false
minimumTlsVersion = "TLS1_2"
networkAcls = {
defaultAction = "Allow"
}
publicNetworkAccess = "Enabled"
supportsHttpsTrafficOnly = true
}
sku = {
name = "Standard_LRS"
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
resource "azapi_resource" "metricAlert" {
type = "Microsoft.Insights/metricAlerts@2018-03-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = "global"
body = {
properties = {
actions = [
]
autoMitigate = true
criteria = {
allOf = [
{
criterionType = "StaticThresholdCriterion"
dimensions = [
]
metricName = "UsedCapacity"
metricNamespace = "Microsoft.Storage/storageAccounts"
name = "Metric1"
operator = "GreaterThan"
skipMetricValidation = false
threshold = 55.5
timeAggregation = "Average"
},
]
"odata.type" = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
}
description = ""
enabled = true
evaluationFrequency = "PT1M"
scopes = [
azapi_resource.storageAccount.id,
]
severity = 3
targetResourceRegion = ""
targetResourceType = ""
windowSize = "PT1H"
}
tags = {
CUSTOMER = "CUSTOMERx"
Example = "Example123"
terraform = "Coolllll"
test = "123"
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Feedback
Was this page helpful?
