Metric Alerts - Update

Update an metric alert definition.

PATCH https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}?api-version=2018-03-01

URI Parameters

Name In Required Type Description
resourceGroupName
path True

string

The name of the resource group. The name is case insensitive.

ruleName
path True

string

The name of the rule.

subscriptionId
path True

string

The ID of the target subscription.

api-version
query True

string

The API version to use for this operation.

Request Body

Name Type Description
properties.actions

MetricAlertAction[]

the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.

properties.autoMitigate

boolean

the flag that indicates whether the alert should be auto resolved or not. The default is true.

properties.criteria MetricAlertCriteria:

defines the specific alert criteria information.

properties.description

string

the description of the metric alert that will be included in the alert email.

properties.enabled

boolean

the flag that indicates whether the metric alert is enabled.

properties.evaluationFrequency

string

how often the metric alert is evaluated represented in ISO 8601 duration format.

properties.scopes

string[]

the list of resource id's that this metric alert is scoped to.

properties.severity

integer

Alert severity {0, 1, 2, 3, 4}

properties.targetResourceRegion

string

the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria.

properties.targetResourceType

string

the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria.

properties.windowSize

string

the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold.

tags

object

Resource tags

Responses

Name Type Description
200 OK

MetricAlertResource

OK

Other Status Codes

ErrorResponse

BadRequest

Security

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

Create or update an alert rule

Sample request

PATCH https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/chiricutin?api-version=2018-03-01

{
  "tags": {},
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
    ],
    "evaluationFrequency": "Pt1m",
    "windowSize": "Pt15m",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "StaticThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "\\Processor(_Total)\\% Processor Time",
          "dimensions": [],
          "operator": "GreaterThan",
          "threshold": 80.5,
          "timeAggregation": "Average"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}

Sample response

{
  "id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin",
  "type": "Microsoft.Insights/metricAlerts",
  "location": "global",
  "tags": {
    "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
  },
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
    ],
    "evaluationFrequency": "Pt1m",
    "windowSize": "Pt15m",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "StaticThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "\\Processor(_Total)\\% Processor Time",
          "dimensions": [],
          "operator": "GreaterThan",
          "threshold": 80.5,
          "timeAggregation": "Average"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}

Definitions

Name Description
AggregationTypeEnum

the criteria time aggregation types.

DynamicMetricCriteria

Criterion for dynamic threshold.

DynamicThresholdFailingPeriods

The minimum number of violations required within the selected lookback time window required to raise an alert.

DynamicThresholdOperator

The operator used to compare the metric value against the threshold.

DynamicThresholdSensitivity

The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern.

ErrorResponse

Describes the format of Error response.

MetricAlertAction

An alert action.

MetricAlertMultipleResourceMultipleMetricCriteria

Specifies the metric alert criteria for multiple resource that has multiple metric criteria.

MetricAlertResource

The metric alert resource.

MetricAlertResourcePatch

The metric alert resource for patch operations.

MetricAlertSingleResourceMultipleMetricCriteria

Specifies the metric alert criteria for a single resource that has multiple metric criteria.

MetricCriteria

Criterion to filter metrics.

MetricDimension

Specifies a metric dimension.

Operator

the criteria operator.

WebtestLocationAvailabilityCriteria

Specifies the metric alert rule criteria for a web test resource.

AggregationTypeEnum

the criteria time aggregation types.

Name Type Description
Average

string

Count

string

Maximum

string

Minimum

string

Total

string

DynamicMetricCriteria

Criterion for dynamic threshold.

Name Type Description
alertSensitivity

DynamicThresholdSensitivity

The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern.

criterionType string:

DynamicThresholdCriterion

Specifies the type of threshold criteria

dimensions

MetricDimension[]

List of dimension conditions.

failingPeriods

DynamicThresholdFailingPeriods

The minimum number of violations required within the selected lookback time window required to raise an alert.

ignoreDataBefore

string

Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format)

metricName

string

Name of the metric.

metricNamespace

string

Namespace of the metric.

name

string

Name of the criteria.

operator

DynamicThresholdOperator

The operator used to compare the metric value against the threshold.

skipMetricValidation

boolean

Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped.

timeAggregation

AggregationTypeEnum

the criteria time aggregation types.

DynamicThresholdFailingPeriods

The minimum number of violations required within the selected lookback time window required to raise an alert.

Name Type Description
minFailingPeriodsToAlert

number

The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods.

numberOfEvaluationPeriods

number

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.

DynamicThresholdOperator

The operator used to compare the metric value against the threshold.

Name Type Description
GreaterOrLessThan

string

GreaterThan

string

LessThan

string

DynamicThresholdSensitivity

The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern.

Name Type Description
High

string

Low

string

Medium

string

ErrorResponse

Describes the format of Error response.

Name Type Description
code

string

Error code

message

string

Error message indicating why the operation failed.

MetricAlertAction

An alert action.

Name Type Description
actionGroupId

string

the id of the action group to use.

webHookProperties

object

This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook.

MetricAlertMultipleResourceMultipleMetricCriteria

Specifies the metric alert criteria for multiple resource that has multiple metric criteria.

Name Type Description
allOf MultiMetricCriteria[]:

the list of multiple metric criteria for this 'all of' operation.

odata.type string:

Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria

specifies the type of the alert criteria.

MetricAlertResource

The metric alert resource.

Name Type Description
id

string

Azure resource Id

location

string

Resource location

name

string

Azure resource name

properties.actions

MetricAlertAction[]

the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.

properties.autoMitigate

boolean

the flag that indicates whether the alert should be auto resolved or not. The default is true.

properties.criteria MetricAlertCriteria:

defines the specific alert criteria information.

properties.description

string

the description of the metric alert that will be included in the alert email.

properties.enabled

boolean

the flag that indicates whether the metric alert is enabled.

properties.evaluationFrequency

string

how often the metric alert is evaluated represented in ISO 8601 duration format.

properties.isMigrated

boolean

the value indicating whether this alert rule is migrated.

properties.lastUpdatedTime

string

Last time the rule was updated in ISO8601 format.

properties.scopes

string[]

the list of resource id's that this metric alert is scoped to.

properties.severity

integer

Alert severity {0, 1, 2, 3, 4}

properties.targetResourceRegion

string

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.

properties.targetResourceType

string

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.

properties.windowSize

string

the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold.

tags

object

Resource tags

type

string

Azure resource type

MetricAlertResourcePatch

The metric alert resource for patch operations.

Name Type Description
properties.actions

MetricAlertAction[]

the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.

properties.autoMitigate

boolean

the flag that indicates whether the alert should be auto resolved or not. The default is true.

properties.criteria MetricAlertCriteria:

defines the specific alert criteria information.

properties.description

string

the description of the metric alert that will be included in the alert email.

properties.enabled

boolean

the flag that indicates whether the metric alert is enabled.

properties.evaluationFrequency

string

how often the metric alert is evaluated represented in ISO 8601 duration format.

properties.isMigrated

boolean

the value indicating whether this alert rule is migrated.

properties.lastUpdatedTime

string

Last time the rule was updated in ISO8601 format.

properties.scopes

string[]

the list of resource id's that this metric alert is scoped to.

properties.severity

integer

Alert severity {0, 1, 2, 3, 4}

properties.targetResourceRegion

string

the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria.

properties.targetResourceType

string

the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria.

properties.windowSize

string

the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold.

tags

object

Resource tags

MetricAlertSingleResourceMultipleMetricCriteria

Specifies the metric alert criteria for a single resource that has multiple metric criteria.

Name Type Description
allOf

MetricCriteria[]

The list of metric criteria for this 'all of' operation.

odata.type string:

Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria

specifies the type of the alert criteria.

MetricCriteria

Criterion to filter metrics.

Name Type Description
criterionType string:

StaticThresholdCriterion

Specifies the type of threshold criteria

dimensions

MetricDimension[]

List of dimension conditions.

metricName

string

Name of the metric.

metricNamespace

string

Namespace of the metric.

name

string

Name of the criteria.

operator

Operator

the criteria operator.

skipMetricValidation

boolean

Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped.

threshold

number

the criteria threshold value that activates the alert.

timeAggregation

AggregationTypeEnum

the criteria time aggregation types.

MetricDimension

Specifies a metric dimension.

Name Type Description
name

string

Name of the dimension.

operator

string

the dimension operator. Only 'Include' and 'Exclude' are supported

values

string[]

list of dimension values.

Operator

the criteria operator.

Name Type Description
Equals

string

GreaterThan

string

GreaterThanOrEqual

string

LessThan

string

LessThanOrEqual

string

WebtestLocationAvailabilityCriteria

Specifies the metric alert rule criteria for a web test resource.

Name Type Description
componentId

string

The Application Insights resource Id.

failedLocationCount

number

The number of failed locations.

odata.type string:

Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria

specifies the type of the alert criteria.

webTestId

string

The Application Insights web test Id.