Microsoft.Insights scheduledQueryRules 2020-05-01-preview

Bicep resource definition

The scheduledQueryRules resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Remarks

For guidance on deploying monitoring solutions, see Create monitoring resources by using Bicep.

Resource format

To create a Microsoft.Insights/scheduledQueryRules resource, add the following Bicep to your template.

resource symbolicname 'Microsoft.Insights/scheduledQueryRules@2020-05-01-preview' = {
  name: 'string'
  location: 'string'
  tags: {
    tagName1: 'tagValue1'
    tagName2: 'tagValue2'
  }
  properties: {
    actions: [
      {
        actionGroupId: 'string'
        webHookProperties: {
          {customized property}: 'string'
        }
      }
    ]
    criteria: {
      allOf: [
        {
          dimensions: [
            {
              name: 'string'
              operator: 'string'
              values: [
                'string'
              ]
            }
          ]
          failingPeriods: {
            minFailingPeriodsToAlert: int
            numberOfEvaluationPeriods: int
          }
          metricMeasureColumn: 'string'
          operator: 'string'
          query: 'string'
          resourceIdColumn: 'string'
          threshold: int
          timeAggregation: 'string'
        }
      ]
    }
    description: 'string'
    displayName: 'string'
    enabled: bool
    evaluationFrequency: 'string'
    muteActionsDuration: 'string'
    overrideQueryTimeRange: 'string'
    scopes: [
      'string'
    ]
    severity: int
    targetResourceTypes: [
      'string'
    ]
    windowSize: 'string'
  }
}

Property values

scheduledQueryRules

Name Description Value
name The resource name string (required)

Character limit: 1-260

Valid characters:
Can't use:
*<>%{}&:\\?/#| or control characters

Can't end with space or period.
location The geo-location where the resource lives string (required)
tags Resource tags. Dictionary of tag names and values. See Tags in templates
properties The rule properties of the resource. ScheduledQueryRuleProperties (required)

ScheduledQueryRuleProperties

Name Description Value
actions Action[]
criteria The rule criteria that defines the conditions of the scheduled query rule. ScheduledQueryRuleCriteria
description The description of the scheduled query rule. string
displayName The display name of the alert rule string
enabled The flag which indicates whether this scheduled query rule is enabled. Value should be true or false bool
evaluationFrequency How often the scheduled query rule is evaluated represented in ISO 8601 duration format. string
muteActionsDuration Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired. string
overrideQueryTimeRange If specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods) string
scopes The list of resource id's that this scheduled query rule is scoped to. string[]
severity Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest int
targetResourceTypes List 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 string[]
windowSize The period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). string

Action

Name Description Value
actionGroupId Action Group resource Id to invoke when the alert fires. string
webHookProperties The properties of a webhook object. ActionWebHookProperties

ActionWebHookProperties

Name Description Value
{customized property} string

ScheduledQueryRuleCriteria

Name Description Value
allOf A list of conditions to evaluate against the specified scopes Condition[]

Condition

Name Description Value
dimensions List of Dimensions conditions Dimension[]
failingPeriods The minimum number of violations required within the selected lookback time window required to raise an alert. ConditionFailingPeriods
metricMeasureColumn The column containing the metric measure number. string
operator The criteria operator. 'Equals'
'GreaterThan'
'GreaterThanOrEqual'
'LessThan'
'LessThanOrEqual' (required)
query Log query alert string
resourceIdColumn The column containing the resource id. The content of the column must be a uri formatted as resource id string
threshold the criteria threshold value that activates the alert. int (required)
timeAggregation Aggregation type 'Average'
'Count'
'Maximum'
'Minimum'
'Total' (required)

Dimension

Name Description Value
name Name of the dimension string (required)
operator Operator for dimension values 'Exclude'
'Include' (required)
values List of dimension values string[] (required)

ConditionFailingPeriods

Name Description Value
minFailingPeriodsToAlert The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. Default value is 1 int
numberOfEvaluationPeriods 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. Default value is 1 int

Quickstart templates

The following quickstart templates deploy this resource type.

Template Description
Create alert rule for azure business continuity items

Deploy to Azure
This templates creates an alert rule and user assigned MSI. It also assigns the MSI reader access to the subscription so that the alert rule has access to query the required protected items and latest recovery point details.

ARM template resource definition

The scheduledQueryRules resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Remarks

For guidance on deploying monitoring solutions, see Create monitoring resources by using Bicep.

Resource format

To create a Microsoft.Insights/scheduledQueryRules resource, add the following JSON to your template.

{
  "type": "Microsoft.Insights/scheduledQueryRules",
  "apiVersion": "2020-05-01-preview",
  "name": "string",
  "location": "string",
  "tags": {
    "tagName1": "tagValue1",
    "tagName2": "tagValue2"
  },
  "properties": {
    "actions": [
      {
        "actionGroupId": "string",
        "webHookProperties": {
          "{customized property}": "string"
        }
      }
    ],
    "criteria": {
      "allOf": [
        {
          "dimensions": [
            {
              "name": "string",
              "operator": "string",
              "values": [ "string" ]
            }
          ],
          "failingPeriods": {
            "minFailingPeriodsToAlert": "int",
            "numberOfEvaluationPeriods": "int"
          },
          "metricMeasureColumn": "string",
          "operator": "string",
          "query": "string",
          "resourceIdColumn": "string",
          "threshold": "int",
          "timeAggregation": "string"
        }
      ]
    },
    "description": "string",
    "displayName": "string",
    "enabled": "bool",
    "evaluationFrequency": "string",
    "muteActionsDuration": "string",
    "overrideQueryTimeRange": "string",
    "scopes": [ "string" ],
    "severity": "int",
    "targetResourceTypes": [ "string" ],
    "windowSize": "string"
  }
}

Property values

scheduledQueryRules

Name Description Value
type The resource type 'Microsoft.Insights/scheduledQueryRules'
apiVersion The resource api version '2020-05-01-preview'
name The resource name string (required)

Character limit: 1-260

Valid characters:
Can't use:
*<>%{}&:\\?/#| or control characters

Can't end with space or period.
location The geo-location where the resource lives string (required)
tags Resource tags. Dictionary of tag names and values. See Tags in templates
properties The rule properties of the resource. ScheduledQueryRuleProperties (required)

ScheduledQueryRuleProperties

Name Description Value
actions Action[]
criteria The rule criteria that defines the conditions of the scheduled query rule. ScheduledQueryRuleCriteria
description The description of the scheduled query rule. string
displayName The display name of the alert rule string
enabled The flag which indicates whether this scheduled query rule is enabled. Value should be true or false bool
evaluationFrequency How often the scheduled query rule is evaluated represented in ISO 8601 duration format. string
muteActionsDuration Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired. string
overrideQueryTimeRange If specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods) string
scopes The list of resource id's that this scheduled query rule is scoped to. string[]
severity Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest int
targetResourceTypes List 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 string[]
windowSize The period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). string

Action

Name Description Value
actionGroupId Action Group resource Id to invoke when the alert fires. string
webHookProperties The properties of a webhook object. ActionWebHookProperties

ActionWebHookProperties

Name Description Value
{customized property} string

ScheduledQueryRuleCriteria

Name Description Value
allOf A list of conditions to evaluate against the specified scopes Condition[]

Condition

Name Description Value
dimensions List of Dimensions conditions Dimension[]
failingPeriods The minimum number of violations required within the selected lookback time window required to raise an alert. ConditionFailingPeriods
metricMeasureColumn The column containing the metric measure number. string
operator The criteria operator. 'Equals'
'GreaterThan'
'GreaterThanOrEqual'
'LessThan'
'LessThanOrEqual' (required)
query Log query alert string
resourceIdColumn The column containing the resource id. The content of the column must be a uri formatted as resource id string
threshold the criteria threshold value that activates the alert. int (required)
timeAggregation Aggregation type 'Average'
'Count'
'Maximum'
'Minimum'
'Total' (required)

Dimension

Name Description Value
name Name of the dimension string (required)
operator Operator for dimension values 'Exclude'
'Include' (required)
values List of dimension values string[] (required)

ConditionFailingPeriods

Name Description Value
minFailingPeriodsToAlert The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. Default value is 1 int
numberOfEvaluationPeriods 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. Default value is 1 int

Quickstart templates

The following quickstart templates deploy this resource type.

Template Description
Create alert rule for azure business continuity items

Deploy to Azure
This templates creates an alert rule and user assigned MSI. It also assigns the MSI reader access to the subscription so that the alert rule has access to query the required protected items and latest recovery point details.

Terraform (AzAPI provider) resource definition

The scheduledQueryRules resource type can be deployed with operations that target:

  • Resource groups

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Insights/scheduledQueryRules resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Insights/scheduledQueryRules@2020-05-01-preview"
  name = "string"
  location = "string"
  parent_id = "string"
  tags = {
    tagName1 = "tagValue1"
    tagName2 = "tagValue2"
  }
  body = jsonencode({
    properties = {
      actions = [
        {
          actionGroupId = "string"
          webHookProperties = {
            {customized property} = "string"
          }
        }
      ]
      criteria = {
        allOf = [
          {
            dimensions = [
              {
                name = "string"
                operator = "string"
                values = [
                  "string"
                ]
              }
            ]
            failingPeriods = {
              minFailingPeriodsToAlert = int
              numberOfEvaluationPeriods = int
            }
            metricMeasureColumn = "string"
            operator = "string"
            query = "string"
            resourceIdColumn = "string"
            threshold = int
            timeAggregation = "string"
          }
        ]
      }
      description = "string"
      displayName = "string"
      enabled = bool
      evaluationFrequency = "string"
      muteActionsDuration = "string"
      overrideQueryTimeRange = "string"
      scopes = [
        "string"
      ]
      severity = int
      targetResourceTypes = [
        "string"
      ]
      windowSize = "string"
    }
  })
}

Property values

scheduledQueryRules

Name Description Value
type The resource type "Microsoft.Insights/scheduledQueryRules@2020-05-01-preview"
name The resource name string (required)

Character limit: 1-260

Valid characters:
Can't use:
*<>%{}&:\\?/#| or control characters

Can't end with space or period.
location The geo-location where the resource lives string (required)
parent_id To deploy to a resource group, use the ID of that resource group. string (required)
tags Resource tags. Dictionary of tag names and values.
properties The rule properties of the resource. ScheduledQueryRuleProperties (required)

ScheduledQueryRuleProperties

Name Description Value
actions Action[]
criteria The rule criteria that defines the conditions of the scheduled query rule. ScheduledQueryRuleCriteria
description The description of the scheduled query rule. string
displayName The display name of the alert rule string
enabled The flag which indicates whether this scheduled query rule is enabled. Value should be true or false bool
evaluationFrequency How often the scheduled query rule is evaluated represented in ISO 8601 duration format. string
muteActionsDuration Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired. string
overrideQueryTimeRange If specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods) string
scopes The list of resource id's that this scheduled query rule is scoped to. string[]
severity Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest int
targetResourceTypes List 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 string[]
windowSize The period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). string

Action

Name Description Value
actionGroupId Action Group resource Id to invoke when the alert fires. string
webHookProperties The properties of a webhook object. ActionWebHookProperties

ActionWebHookProperties

Name Description Value
{customized property} string

ScheduledQueryRuleCriteria

Name Description Value
allOf A list of conditions to evaluate against the specified scopes Condition[]

Condition

Name Description Value
dimensions List of Dimensions conditions Dimension[]
failingPeriods The minimum number of violations required within the selected lookback time window required to raise an alert. ConditionFailingPeriods
metricMeasureColumn The column containing the metric measure number. string
operator The criteria operator. "Equals"
"GreaterThan"
"GreaterThanOrEqual"
"LessThan"
"LessThanOrEqual" (required)
query Log query alert string
resourceIdColumn The column containing the resource id. The content of the column must be a uri formatted as resource id string
threshold the criteria threshold value that activates the alert. int (required)
timeAggregation Aggregation type "Average"
"Count"
"Maximum"
"Minimum"
"Total" (required)

Dimension

Name Description Value
name Name of the dimension string (required)
operator Operator for dimension values "Exclude"
"Include" (required)
values List of dimension values string[] (required)

ConditionFailingPeriods

Name Description Value
minFailingPeriodsToAlert The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. Default value is 1 int
numberOfEvaluationPeriods 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. Default value is 1 int