Skip to main content

metric_alerts

Creates, updates, deletes, gets or lists a metric_alerts resource.

Overview

Namemetric_alerts
TypeResource
Idazure.monitor.metric_alerts

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringFully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
namestringThe name of the resource.
actionPropertiesobjectThe properties of an action properties.
actionsarrayThe array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.
autoMitigatebooleanThe flag that indicates whether the alert should be auto resolved or not. The default is true.
criteriaobjectDefines the specific alert criteria information. Required.
customPropertiesobjectThe properties of an alert payload.
descriptionstringThe description of the metric alert that will be included in the alert email.
enabledbooleanThe flag that indicates whether the metric alert is enabled. Required.
evaluationFrequencystringHow often the metric alert is evaluated represented in ISO 8601 duration format. Required.
identityobjectThe identity of the resource.
isMigratedbooleanThe value indicating whether this alert rule is migrated.
lastUpdatedTimestring (date-time)Last time the rule was updated in ISO8601 format.
locationstringThe geo-location where the resource lives. Required.
resolveConfigurationobjectThe configuration for how the alert is resolved. Applicable for PromQLCriteria.
scopesarrayThe 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.
severityintegerAlert severity {0, 1, 2, 3, 4}. Required.
systemDataobjectAzure Resource Manager metadata containing createdBy and modifiedBy information.
tagsobjectResource tags.
targetResourceRegionstringThe 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.
targetResourceTypestringThe 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.
typestringThe type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts".
windowSizestringThe 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:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectresource_group_name, rule_name, subscription_idRetrieve an alert rule definition.
list_by_resource_groupselectresource_group_name, subscription_idRetrieve alert rule definitions in a resource group.
list_by_subscriptionselectsubscription_idRetrieve alert rule definitions in a subscription.
create_or_updateinsertresource_group_name, rule_name, subscription_id, location, propertiesCreate or update an metric alert definition.
updateupdateresource_group_name, rule_name, subscription_idUpdate an metric alert definition.
create_or_updatereplaceresource_group_name, rule_name, subscription_id, location, propertiesCreate or update an metric alert definition.
deletedeleteresource_group_name, rule_name, subscription_idDelete 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.

NameDatatypeDescription
resource_group_namestringThe name of the resource group. The name is case insensitive. Required.
rule_namestringThe name of the rule. Required.
subscription_idstring

SELECT examples

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
;

INSERT examples

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
;

UPDATE examples

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 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 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
;