Skip to main content

scheduled_query_rules

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

Overview

Namescheduled_query_rules
TypeResource
Idazure.monitor.scheduled_query_rules

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.
actionsobjectActions to invoke when the alert fires.
autoMitigatebooleanThe flag that indicates whether the alert should be automatically resolved or not. The default is true. Relevant only for rules of kinds LogAlert and SimpleLogAlert.
checkWorkspaceAlertsStorageConfiguredbooleanThe flag which indicates whether this scheduled query rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind LogAlert.
createdWithApiVersionstringThe api-version used when creating this alert rule.
criteriaobjectThe rule criteria that defines the conditions of the scheduled query rule.
descriptionstringThe description of the scheduled query rule.
displayNamestringThe display name of the alert rule.
enabledbooleanThe flag which indicates whether this scheduled query rule is enabled. Value should be true or false.
etagstringResource entity tag (ETag).
evaluationFrequencystringHow often the scheduled query rule is evaluated represented in ISO 8601 duration format. Relevant and required only for rules of the kind LogAlert.
identityobjectThe identity of the resource.
isLegacyLogAnalyticsRulebooleanTrue if alert rule is legacy Log Analytic rule.
isWorkspaceAlertsStorageConfiguredbooleanThe flag which indicates whether this scheduled query rule has been configured to be stored in the customer's storage. The default is false.
kindstringIndicates the type of scheduled query rule. The default is LogAlert. Known values are: "LogAlert", "SimpleLogAlert", and "LogToMetric". (LogAlert, SimpleLogAlert, LogToMetric)
locationstringThe geo-location where the resource lives. Required.
muteActionsDurationstringMute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired. Relevant only for rules of the kind LogAlert.
overrideQueryTimeRangestringIf specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert.
resolveConfigurationobjectDefines the configuration for resolving fired alerts. Relevant only for rules of kinds LogAlert and SimpleLogAlert.
scopesarrayThe list of resource id's that this scheduled query rule is scoped to.
severityobjectSeverity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Relevant and required only for rules of the kind LogAlert. Known values are: 0, 1, 2, 3, and 4.
skipQueryValidationbooleanThe flag which indicates whether the provided query should be validated or not. The default is false. Relevant only for rules of the kind LogAlert.
systemDataobjectAzure Resource Manager metadata containing createdBy and modifiedBy information.
tagsobjectResource tags.
targetResourceTypesarrayList of resource type of the target resource(s) on which the alert is created/updated. For example if the scope is a resource group and targetResourceTypes is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource group which meet the alert criteria. Relevant only for rules of the kind LogAlert.
typestringThe type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts".
windowSizestringThe period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). Relevant and required only for rules of the kind LogAlert.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectresource_group_name, rule_name, subscription_idRetrieve an scheduled query rule definition.
list_by_resource_groupselectresource_group_name, subscription_idRetrieve scheduled query rule definitions in a resource group.
list_by_subscriptionselectsubscription_idRetrieve a scheduled query rule definitions in a subscription.
create_or_updateinsertresource_group_name, rule_name, subscription_id, properties, locationCreates or updates a scheduled query rule.
updateupdateresource_group_name, rule_name, subscription_idUpdate a scheduled query rule.
create_or_updatereplaceresource_group_name, rule_name, subscription_id, properties, locationCreates or updates a scheduled query rule.
deletedeleteresource_group_name, rule_name, subscription_idDeletes a scheduled query rule.

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 scheduled query rule definition.

SELECT
id,
name,
actions,
autoMitigate,
checkWorkspaceAlertsStorageConfigured,
createdWithApiVersion,
criteria,
description,
displayName,
enabled,
etag,
evaluationFrequency,
identity,
isLegacyLogAnalyticsRule,
isWorkspaceAlertsStorageConfigured,
kind,
location,
muteActionsDuration,
overrideQueryTimeRange,
resolveConfiguration,
scopes,
severity,
skipQueryValidation,
systemData,
tags,
targetResourceTypes,
type,
windowSize
FROM azure.monitor.scheduled_query_rules
WHERE resource_group_name = '{{ resource_group_name }}' -- required
AND rule_name = '{{ rule_name }}' -- required
AND subscription_id = '{{ subscription_id }}' -- required
;

INSERT examples

Creates or updates a scheduled query rule.

INSERT INTO azure.monitor.scheduled_query_rules (
properties,
identity,
tags,
location,
kind,
resource_group_name,
rule_name,
subscription_id
)
SELECT
'{{ properties }}' /* required */,
'{{ identity }}',
'{{ tags }}',
'{{ location }}' /* required */,
'{{ kind }}',
'{{ resource_group_name }}',
'{{ rule_name }}',
'{{ subscription_id }}'
RETURNING
id,
name,
etag,
identity,
kind,
location,
properties,
systemData,
tags,
type
;

UPDATE examples

Update a scheduled query rule.

UPDATE azure.monitor.scheduled_query_rules
SET
identity = '{{ identity }}',
tags = '{{ tags }}',
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,
etag,
identity,
kind,
location,
properties,
systemData,
tags,
type;

REPLACE examples

Creates or updates a scheduled query rule.

REPLACE azure.monitor.scheduled_query_rules
SET
properties = '{{ properties }}',
identity = '{{ identity }}',
tags = '{{ tags }}',
location = '{{ location }}',
kind = '{{ kind }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND rule_name = '{{ rule_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
AND properties = '{{ properties }}' --required
AND location = '{{ location }}' --required
RETURNING
id,
name,
etag,
identity,
kind,
location,
properties,
systemData,
tags,
type;

DELETE examples

Deletes a scheduled query rule.

DELETE FROM azure.monitor.scheduled_query_rules
WHERE resource_group_name = '{{ resource_group_name }}' --required
AND rule_name = '{{ rule_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
;