Microsoft.Insights metricAlerts

Template format

To create a Microsoft.Insights/metricAlerts resource, add the following JSON to the resources section of your template.

{
  "name": "string",
  "type": "Microsoft.Insights/metricAlerts",
  "apiVersion": "2018-03-01",
  "location": "string",
  "tags": {},
  "properties": {
    "description": "string",
    "severity": "integer",
    "enabled": "boolean",
    "scopes": [
      "string"
    ],
    "evaluationFrequency": "string",
    "windowSize": "string",
    "targetResourceType": "string",
    "targetResourceRegion": "string",
    "criteria": {
      "additionalProperties": {},
      "odata.type": "string",
      "allOf": [
          { }
      ]
    },
    "autoMitigate": "boolean",
    "actions": [
      {
        "actionGroupId": "string",
        "webHookProperties": {}
      }
    ]
  }
}

The criteria.allOf property varies by object type.

For SingleResourceMultipleMetricCriteria object, use:

{
  "criterionType": "string",
  "dimensions": [],
  "metricName": "string",
  "metricNamespace": "string",
  "name": "string",
  "operator": "string",
  "threshold": "integer",
  "timeAggregation": "string"
}

For MultipleResourceMultipleMetricCriteria object, use:

{
  "criterionType": "string",
  "dimensions": [],
  "metricName": "string",
  "metricNamespace": "string",
  "name": "string",
  "operator": "string",
  "threshold": "integer",
  "timeAggregation": "string",
  "alertSensitivity": "string",
  "failingPeriods": {
    "minFailingPeriodsToAlert": "integer",
    "numberOfEvaluationPeriods": "integer"
  },
  "ignoreDataBefore": "string"
}

For WebtestLocationAvailabilityCriteria, use:

{
  "webTestId": "string",
  "componentId": "string",
  "failedLocationCount": "integer"
}

Property values

The following tables describe the values you need to set in the schema.

Microsoft.Insights/metricAlerts object

Note

In Bicep, type and apiVersion are specified in the first line of the resource declaration. Use the format <type>@<apiVersion>. Don't set those properties in the resource body.

Name Type Required Value
name string Yes The name of the rule.
type enum Yes For JSON - Microsoft.Insights/metricAlerts
apiVersion enum Yes For JSON - 2018-03-01
location string Yes Resource location
tags object No Resource tags
properties object Yes The alert rule properties of the resource. - MetricAlertProperties object

MetricAlertProperties object

Name Type Required Value
description string No the description of the metric alert that will be included in the alert email.
severity integer Yes Alert severity {0, 1, 2, 3, 4}
enabled boolean Yes the flag that indicates whether the metric alert is enabled.
scopes array Yes the list of resource id's that this metric alert is scoped to. - string
evaluationFrequency string Yes how often the metric alert is evaluated represented in ISO 8601 duration format.
windowSize string Yes the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold.
targetResourceType string No 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.
targetResourceRegion string No 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.
criteria object Yes defines the specific alert criteria information. - MetricAlertCriteria object
autoMitigate boolean No the flag that indicates whether the alert should be auto resolved or not. The default is true.
actions array No the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - MetricAlertAction object

MetricAlertCriteria object

Name Type Required Value
additionalProperties object No Unmatched properties from the message are deserialized this collection
odata.type string Yes specifies the type of the alert criteria. - Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria, Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria or Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria
allOf array No Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria object, Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria or Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria

SingleResourceMultipleMetricCriteria object

Name Type Required Value
criterionType string Yes Specifies the type of threshold criteria - StaticThresholdCriterion
dimensions array No List of dimension conditions. - MetricDimension
metricName string Yes Name of the metric.
metricNamespace string No Namespace of the metric.
name string Yes Name of the criteria.
operator string Yes the criteria operator. - Equals, NotEquals, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual
threshold integer Yes the criteria threshold value that activates the alert.
timeAggregation string Yes the criteria time aggregation types. - Average, Minimum, Maximum, Total

MultipleResourceMultipleMetricCriteria object

Name Type Required Value
criterionType string Yes Specifies the type of threshold criteria - DynamicThresholdCriterion
dimensions array No List of dimension conditions. - MetricDimension
metricName string Yes Name of the metric.
metricNamespace string No Namespace of the metric.
name string Yes Name of the criteria.
operator string Yes the criteria operator. - Equals, NotEquals, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual
threshold integer Yes the criteria threshold value that activates the alert.
timeAggregation string Yes the criteria time aggregation types. - Average, Minimum, Maximum, Total
alertSensitivity string Yes The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. - Low, Medium, High
failingPeriods object Yes The minimum number of violations required within the selected lookback time window required to raise an alert. - failingPeriods
ignoreDataBefore string No Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format)

WebtestLocationAvailabilityCriteria object

Name Type Required Value
webTestId string Yes The Application Insights web test Id.
componentId string Yes The Application Insights resource Id.
failedLocationCount integer Yes The number of failed locations.

MetricDimension object

Name Type Required Value
name string Yes Name of the dimension.
operator string Yes the dimension operator. Only 'Include' and 'Exclude' are supported
values array Yes list of dimension values.

FailingPeriods object

Name Type Required Value
minFailingPeriodsToAlert integer Yes The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods.
numberOfEvaluationPeriods integer Yes 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.

MetricAlertAction object

Name Type Required Value
actionGroupId string No the id of the action group to use.
webHookProperties object No This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook.

Quickstart templates

The following quickstart templates deploy this resource type.

Template Description
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.
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.
Deploy Application Insight and create alert in it

Deploy to Azure
This template allows you to deploy Application Insight and create alert in it