metric_alerts
Creates, updates, deletes, gets or lists a metric_alerts resource.
Overview
| Name | metric_alerts |
| Type | Resource |
| Id | azure.monitor.metric_alerts |
Fields
The following fields are returned by SELECT queries:
- get
- list_by_resource_group
- list_by_subscription
| Name | Datatype | Description |
|---|---|---|
id | string | Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. |
name | string | The name of the resource. |
actionProperties | object | The properties of an action properties. |
actions | array | The array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. |
autoMitigate | boolean | The flag that indicates whether the alert should be auto resolved or not. The default is true. |
criteria | object | Defines the specific alert criteria information. Required. |
customProperties | object | The properties of an alert payload. |
description | string | The description of the metric alert that will be included in the alert email. |
enabled | boolean | The flag that indicates whether the metric alert is enabled. Required. |
evaluationFrequency | string | How often the metric alert is evaluated represented in ISO 8601 duration format. Required. |
identity | object | The identity of the resource. |
isMigrated | boolean | The value indicating whether this alert rule is migrated. |
lastUpdatedTime | string (date-time) | Last time the rule was updated in ISO8601 format. |
location | string | The geo-location where the resource lives. Required. |
resolveConfiguration | object | The configuration for how the alert is resolved. Applicable for PromQLCriteria. |
scopes | array | 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. Required. |
severity | integer | Alert severity {0, 1, 2, 3, 4}. Required. |
systemData | object | Azure Resource Manager metadata containing createdBy and modifiedBy information. |
tags | object | Resource tags. |
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. |
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. |
type | string | The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". |
windowSize | string | The period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. |
| Name | Datatype | Description |
|---|---|---|
id | string | Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. |
name | string | The name of the resource. |
actionProperties | object | The properties of an action properties. |
actions | array | The array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. |
autoMitigate | boolean | The flag that indicates whether the alert should be auto resolved or not. The default is true. |
criteria | object | Defines the specific alert criteria information. Required. |
customProperties | object | The properties of an alert payload. |
description | string | The description of the metric alert that will be included in the alert email. |
enabled | boolean | The flag that indicates whether the metric alert is enabled. Required. |
evaluationFrequency | string | How often the metric alert is evaluated represented in ISO 8601 duration format. Required. |
identity | object | The identity of the resource. |
isMigrated | boolean | The value indicating whether this alert rule is migrated. |
lastUpdatedTime | string (date-time) | Last time the rule was updated in ISO8601 format. |
location | string | The geo-location where the resource lives. Required. |
resolveConfiguration | object | The configuration for how the alert is resolved. Applicable for PromQLCriteria. |
scopes | array | 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. Required. |
severity | integer | Alert severity {0, 1, 2, 3, 4}. Required. |
systemData | object | Azure Resource Manager metadata containing createdBy and modifiedBy information. |
tags | object | Resource tags. |
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. |
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. |
type | string | The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". |
windowSize | string | The period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. |
| Name | Datatype | Description |
|---|---|---|
id | string | Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. |
name | string | The name of the resource. |
actionProperties | object | The properties of an action properties. |
actions | array | The array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. |
autoMitigate | boolean | The flag that indicates whether the alert should be auto resolved or not. The default is true. |
criteria | object | Defines the specific alert criteria information. Required. |
customProperties | object | The properties of an alert payload. |
description | string | The description of the metric alert that will be included in the alert email. |
enabled | boolean | The flag that indicates whether the metric alert is enabled. Required. |
evaluationFrequency | string | How often the metric alert is evaluated represented in ISO 8601 duration format. Required. |
identity | object | The identity of the resource. |
isMigrated | boolean | The value indicating whether this alert rule is migrated. |
lastUpdatedTime | string (date-time) | Last time the rule was updated in ISO8601 format. |
location | string | The geo-location where the resource lives. Required. |
resolveConfiguration | object | The configuration for how the alert is resolved. Applicable for PromQLCriteria. |
scopes | array | 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. Required. |
severity | integer | Alert severity {0, 1, 2, 3, 4}. Required. |
systemData | object | Azure Resource Manager metadata containing createdBy and modifiedBy information. |
tags | object | Resource tags. |
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. |
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. |
type | string | The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". |
windowSize | string | The period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | resource_group_name, rule_name, subscription_id | Retrieve an alert rule definition. | |
list_by_resource_group | select | resource_group_name, subscription_id | Retrieve alert rule definitions in a resource group. | |
list_by_subscription | select | subscription_id | Retrieve alert rule definitions in a subscription. | |
create_or_update | insert | resource_group_name, rule_name, subscription_id, location, properties | Create or update an metric alert definition. | |
update | update | resource_group_name, rule_name, subscription_id | Update an metric alert definition. | |
create_or_update | replace | resource_group_name, rule_name, subscription_id, location, properties | Create or update an metric alert definition. | |
delete | delete | resource_group_name, rule_name, subscription_id | Delete an alert rule definition. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
resource_group_name | string | The name of the resource group. The name is case insensitive. Required. |
rule_name | string | The name of the rule. Required. |
subscription_id | string |
SELECT examples
- get
- list_by_resource_group
- list_by_subscription
Retrieve an alert rule definition.
SELECT
id,
name,
actionProperties,
actions,
autoMitigate,
criteria,
customProperties,
description,
enabled,
evaluationFrequency,
identity,
isMigrated,
lastUpdatedTime,
location,
resolveConfiguration,
scopes,
severity,
systemData,
tags,
targetResourceRegion,
targetResourceType,
type,
windowSize
FROM azure.monitor.metric_alerts
WHERE resource_group_name = '{{ resource_group_name }}' -- required
AND rule_name = '{{ rule_name }}' -- required
AND subscription_id = '{{ subscription_id }}' -- required
;
Retrieve alert rule definitions in a resource group.
SELECT
id,
name,
actionProperties,
actions,
autoMitigate,
criteria,
customProperties,
description,
enabled,
evaluationFrequency,
identity,
isMigrated,
lastUpdatedTime,
location,
resolveConfiguration,
scopes,
severity,
systemData,
tags,
targetResourceRegion,
targetResourceType,
type,
windowSize
FROM azure.monitor.metric_alerts
WHERE resource_group_name = '{{ resource_group_name }}' -- required
AND subscription_id = '{{ subscription_id }}' -- required
;
Retrieve alert rule definitions in a subscription.
SELECT
id,
name,
actionProperties,
actions,
autoMitigate,
criteria,
customProperties,
description,
enabled,
evaluationFrequency,
identity,
isMigrated,
lastUpdatedTime,
location,
resolveConfiguration,
scopes,
severity,
systemData,
tags,
targetResourceRegion,
targetResourceType,
type,
windowSize
FROM azure.monitor.metric_alerts
WHERE subscription_id = '{{ subscription_id }}' -- required
;
INSERT examples
- create_or_update
- Manifest
Create or update an metric alert definition.
INSERT INTO azure.monitor.metric_alerts (
tags,
location,
properties,
identity,
resource_group_name,
rule_name,
subscription_id
)
SELECT
'{{ tags }}',
'{{ location }}' /* required */,
'{{ properties }}' /* required */,
'{{ identity }}',
'{{ resource_group_name }}',
'{{ rule_name }}',
'{{ subscription_id }}'
RETURNING
id,
name,
identity,
location,
properties,
systemData,
tags,
type
;
# Description fields are for documentation purposes
- name: metric_alerts
props:
- name: resource_group_name
value: "{{ resource_group_name }}"
description: Required parameter for the metric_alerts resource.
- name: rule_name
value: "{{ rule_name }}"
description: Required parameter for the metric_alerts resource.
- name: subscription_id
value: "{{ subscription_id }}"
description: Required parameter for the metric_alerts resource.
- name: tags
value: "{{ tags }}"
description: |
Resource tags.
- name: location
value: "{{ location }}"
description: |
The geo-location where the resource lives. Required.
- name: properties
description: |
The alert rule properties of the resource. Required.
value:
description: "{{ description }}"
severity: {{ severity }}
enabled: {{ enabled }}
scopes:
- "{{ scopes }}"
evaluationFrequency: "{{ evaluationFrequency }}"
windowSize: "{{ windowSize }}"
targetResourceType: "{{ targetResourceType }}"
targetResourceRegion: "{{ targetResourceRegion }}"
criteria:
odata:
type: "{{ type }}"
autoMitigate: {{ autoMitigate }}
resolveConfiguration:
autoResolved: {{ autoResolved }}
timeToResolve: "{{ timeToResolve }}"
actions:
- actionGroupId: "{{ actionGroupId }}"
webHookProperties: "{{ webHookProperties }}"
lastUpdatedTime: "{{ lastUpdatedTime }}"
isMigrated: {{ isMigrated }}
customProperties: "{{ customProperties }}"
actionProperties: "{{ actionProperties }}"
- name: identity
description: |
The identity of the resource.
value:
principalId: "{{ principalId }}"
tenantId: "{{ tenantId }}"
type: "{{ type }}"
userAssignedIdentities: "{{ userAssignedIdentities }}"
UPDATE examples
- update
Update an metric alert definition.
UPDATE azure.monitor.metric_alerts
SET
tags = '{{ tags }}',
identity = '{{ identity }}',
properties = '{{ properties }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND rule_name = '{{ rule_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
RETURNING
id,
name,
identity,
location,
properties,
systemData,
tags,
type;
REPLACE examples
- create_or_update
Create or update an metric alert definition.
REPLACE azure.monitor.metric_alerts
SET
tags = '{{ tags }}',
location = '{{ location }}',
properties = '{{ properties }}',
identity = '{{ identity }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND rule_name = '{{ rule_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
AND location = '{{ location }}' --required
AND properties = '{{ properties }}' --required
RETURNING
id,
name,
identity,
location,
properties,
systemData,
tags,
type;
DELETE examples
- delete
Delete an alert rule definition.
DELETE FROM azure.monitor.metric_alerts
WHERE resource_group_name = '{{ resource_group_name }}' --required
AND rule_name = '{{ rule_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
;