Microsoft.Insights scheduledQueryRules 2018-04-16
Remarks
For guidance on deploying monitoring solutions, see Create monitoring resources by using Bicep.
Bicep resource definition
The scheduledQueryRules resource type can be deployed with operations that target:
- Resource groups - See resource group deployment commands
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 Bicep to your template.
resource symbolicname 'Microsoft.Insights/scheduledQueryRules@2018-04-16' = {
location: 'string'
name: 'string'
properties: {
action: {
odata.type: 'string'
// For remaining properties, see Action objects
}
autoMitigate: bool
description: 'string'
displayName: 'string'
enabled: 'string'
schedule: {
frequencyInMinutes: int
timeWindowInMinutes: int
}
source: {
authorizedResources: [
'string'
]
dataSourceId: 'string'
query: 'string'
queryType: 'string'
}
}
tags: {
{customized property}: 'string'
}
}
Action objects
Set the odata.type property to specify the type of object.
For Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction, use:
{
aznsAction: {
actionGroup: [
'string'
]
customWebhookPayload: 'string'
emailSubject: 'string'
}
odata.type: 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction'
severity: 'string'
throttlingInMin: int
trigger: {
metricTrigger: {
metricColumn: 'string'
metricTriggerType: 'string'
threshold: int
thresholdOperator: 'string'
}
threshold: int
thresholdOperator: 'string'
}
}
For Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction, use:
{
criteria: [
{
dimensions: [
{
name: 'string'
operator: 'string'
values: [
'string'
]
}
]
metricName: 'string'
}
]
odata.type: 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction'
}
Property Values
Action
Name | Description | Value |
---|---|---|
odata.type | Set to 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' for type AlertingAction. Set to 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' for type LogToMetricAction. | 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' (required) |
AlertingAction
Name | Description | Value |
---|---|---|
aznsAction | Azure action group reference. | AzNsActionGroup |
odata.type | Specifies the action. Supported values - AlertingAction, LogToMetricAction | 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' (required) |
severity | Severity of the alert | '0' '1' '2' '3' '4' (required) |
throttlingInMin | time (in minutes) for which Alerts should be throttled or suppressed. | int |
trigger | The trigger condition that results in the alert rule being. | TriggerCondition (required) |
AzNsActionGroup
Name | Description | Value |
---|---|---|
actionGroup | Azure Action Group reference. | string[] |
customWebhookPayload | Custom payload to be sent for all webhook URI in Azure action group | string |
emailSubject | Custom subject override for all email ids in Azure action group | string |
Criteria
Name | Description | Value |
---|---|---|
dimensions | List of Dimensions for creating metric | Dimension[] |
metricName | Name of the metric | string (required) |
Dimension
Name | Description | Value |
---|---|---|
name | Name of the dimension | string (required) |
operator | Operator for dimension values | 'Include' (required) |
values | List of dimension values | string[] (required) |
LogMetricTrigger
Name | Description | Value |
---|---|---|
metricColumn | Evaluation of metric on a particular column | string |
metricTriggerType | Metric Trigger Type - 'Consecutive' or 'Total' | 'Consecutive' 'Total' |
threshold | The threshold of the metric trigger. | int |
thresholdOperator | Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. | 'Equal' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' |
LogSearchRule
Name | Description | Value |
---|---|---|
action | Action needs to be taken on rule execution. | Action (required) |
autoMitigate | The flag that indicates whether the alert should be automatically resolved or not. The default is false. | bool |
description | The description of the Log Search rule. | string |
displayName | The display name of the alert rule | string |
enabled | The flag which indicates whether the Log Search rule is enabled. Value should be true or false | 'false' 'true' |
schedule | Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction | Schedule |
source | Data Source against which rule will Query Data | Source (required) |
LogToMetricAction
Name | Description | Value |
---|---|---|
criteria | Criteria of Metric | Criteria[] (required) |
odata.type | Specifies the action. Supported values - AlertingAction, LogToMetricAction | 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' (required) |
Microsoft.Insights/scheduledQueryRules
Name | Description | Value |
---|---|---|
location | Resource location | string (required) |
name | The resource name | string (required) |
properties | The rule properties of the resource. | LogSearchRule (required) |
tags | Resource tags | Dictionary of tag names and values. See Tags in templates |
ResourceTags
Name | Description | Value |
---|
Schedule
Name | Description | Value |
---|---|---|
frequencyInMinutes | frequency (in minutes) at which rule condition should be evaluated. | int (required) |
timeWindowInMinutes | Time window for which data needs to be fetched for query (should be greater than or equal to frequencyInMinutes). | int (required) |
Source
Name | Description | Value |
---|---|---|
authorizedResources | List of Resource referred into query | string[] |
dataSourceId | The resource uri over which log search query is to be run. | string (required) |
query | Log search query. Required for action type - AlertingAction | string |
queryType | Set value to 'ResultCount' . | 'ResultCount' |
TriggerCondition
Name | Description | Value |
---|---|---|
metricTrigger | Trigger condition for metric query rule | LogMetricTrigger |
threshold | Result or count threshold based on which rule should be triggered. | int (required) |
thresholdOperator | Evaluation operation for rule - 'GreaterThan' or 'LessThan. | 'Equal' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' (required) |
Usage Examples
Azure Verified Modules
The following Azure Verified Modules can be used to deploy this resource type.
Module | Description |
---|---|
Scheduled Query Rule | AVM Resource Module for Scheduled Query Rule |
ARM template resource definition
The scheduledQueryRules resource type can be deployed with operations that target:
- Resource groups - See resource group deployment commands
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 JSON to your template.
{
"type": "Microsoft.Insights/scheduledQueryRules",
"apiVersion": "2018-04-16",
"name": "string",
"location": "string",
"properties": {
"action": {
"odata.type": "string"
// For remaining properties, see Action objects
},
"autoMitigate": "bool",
"description": "string",
"displayName": "string",
"enabled": "string",
"schedule": {
"frequencyInMinutes": "int",
"timeWindowInMinutes": "int"
},
"source": {
"authorizedResources": [ "string" ],
"dataSourceId": "string",
"query": "string",
"queryType": "string"
}
},
"tags": {
"{customized property}": "string"
}
}
Action objects
Set the odata.type property to specify the type of object.
For Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction, use:
{
"aznsAction": {
"actionGroup": [ "string" ],
"customWebhookPayload": "string",
"emailSubject": "string"
},
"odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction",
"severity": "string",
"throttlingInMin": "int",
"trigger": {
"metricTrigger": {
"metricColumn": "string",
"metricTriggerType": "string",
"threshold": "int",
"thresholdOperator": "string"
},
"threshold": "int",
"thresholdOperator": "string"
}
}
For Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction, use:
{
"criteria": [
{
"dimensions": [
{
"name": "string",
"operator": "string",
"values": [ "string" ]
}
],
"metricName": "string"
}
],
"odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction"
}
Property Values
Action
Name | Description | Value |
---|---|---|
odata.type | Set to 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' for type AlertingAction. Set to 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' for type LogToMetricAction. | 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' (required) |
AlertingAction
Name | Description | Value |
---|---|---|
aznsAction | Azure action group reference. | AzNsActionGroup |
odata.type | Specifies the action. Supported values - AlertingAction, LogToMetricAction | 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' (required) |
severity | Severity of the alert | '0' '1' '2' '3' '4' (required) |
throttlingInMin | time (in minutes) for which Alerts should be throttled or suppressed. | int |
trigger | The trigger condition that results in the alert rule being. | TriggerCondition (required) |
AzNsActionGroup
Name | Description | Value |
---|---|---|
actionGroup | Azure Action Group reference. | string[] |
customWebhookPayload | Custom payload to be sent for all webhook URI in Azure action group | string |
emailSubject | Custom subject override for all email ids in Azure action group | string |
Criteria
Name | Description | Value |
---|---|---|
dimensions | List of Dimensions for creating metric | Dimension[] |
metricName | Name of the metric | string (required) |
Dimension
Name | Description | Value |
---|---|---|
name | Name of the dimension | string (required) |
operator | Operator for dimension values | 'Include' (required) |
values | List of dimension values | string[] (required) |
LogMetricTrigger
Name | Description | Value |
---|---|---|
metricColumn | Evaluation of metric on a particular column | string |
metricTriggerType | Metric Trigger Type - 'Consecutive' or 'Total' | 'Consecutive' 'Total' |
threshold | The threshold of the metric trigger. | int |
thresholdOperator | Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. | 'Equal' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' |
LogSearchRule
Name | Description | Value |
---|---|---|
action | Action needs to be taken on rule execution. | Action (required) |
autoMitigate | The flag that indicates whether the alert should be automatically resolved or not. The default is false. | bool |
description | The description of the Log Search rule. | string |
displayName | The display name of the alert rule | string |
enabled | The flag which indicates whether the Log Search rule is enabled. Value should be true or false | 'false' 'true' |
schedule | Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction | Schedule |
source | Data Source against which rule will Query Data | Source (required) |
LogToMetricAction
Name | Description | Value |
---|---|---|
criteria | Criteria of Metric | Criteria[] (required) |
odata.type | Specifies the action. Supported values - AlertingAction, LogToMetricAction | 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' (required) |
Microsoft.Insights/scheduledQueryRules
Name | Description | Value |
---|---|---|
apiVersion | The api version | '2018-04-16' |
location | Resource location | string (required) |
name | The resource name | string (required) |
properties | The rule properties of the resource. | LogSearchRule (required) |
tags | Resource tags | Dictionary of tag names and values. See Tags in templates |
type | The resource type | 'Microsoft.Insights/scheduledQueryRules' |
ResourceTags
Name | Description | Value |
---|
Schedule
Name | Description | Value |
---|---|---|
frequencyInMinutes | frequency (in minutes) at which rule condition should be evaluated. | int (required) |
timeWindowInMinutes | Time window for which data needs to be fetched for query (should be greater than or equal to frequencyInMinutes). | int (required) |
Source
Name | Description | Value |
---|---|---|
authorizedResources | List of Resource referred into query | string[] |
dataSourceId | The resource uri over which log search query is to be run. | string (required) |
query | Log search query. Required for action type - AlertingAction | string |
queryType | Set value to 'ResultCount' . | 'ResultCount' |
TriggerCondition
Name | Description | Value |
---|---|---|
metricTrigger | Trigger condition for metric query rule | LogMetricTrigger |
threshold | Result or count threshold based on which rule should be triggered. | int (required) |
thresholdOperator | Evaluation operation for rule - 'GreaterThan' or 'LessThan. | 'Equal' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' (required) |
Usage Examples
Azure Quickstart Templates
The following Azure Quickstart templates deploy this resource type.
Template | Description |
---|---|
Create alert rule for azure business continuity items |
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@2018-04-16"
name = "string"
location = "string"
tags = {
{customized property} = "string"
}
body = jsonencode({
properties = {
action = {
odata.type = "string"
// For remaining properties, see Action objects
}
autoMitigate = bool
description = "string"
displayName = "string"
enabled = "string"
schedule = {
frequencyInMinutes = int
timeWindowInMinutes = int
}
source = {
authorizedResources = [
"string"
]
dataSourceId = "string"
query = "string"
queryType = "string"
}
}
})
}
Action objects
Set the odata.type property to specify the type of object.
For Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction, use:
{
aznsAction = {
actionGroup = [
"string"
]
customWebhookPayload = "string"
emailSubject = "string"
}
odata.type = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"
severity = "string"
throttlingInMin = int
trigger = {
metricTrigger = {
metricColumn = "string"
metricTriggerType = "string"
threshold = int
thresholdOperator = "string"
}
threshold = int
thresholdOperator = "string"
}
}
For Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction, use:
{
criteria = [
{
dimensions = [
{
name = "string"
operator = "string"
values = [
"string"
]
}
]
metricName = "string"
}
]
odata.type = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction"
}
Property Values
Action
Name | Description | Value |
---|---|---|
odata.type | Set to 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' for type AlertingAction. Set to 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' for type LogToMetricAction. | 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' (required) |
AlertingAction
Name | Description | Value |
---|---|---|
aznsAction | Azure action group reference. | AzNsActionGroup |
odata.type | Specifies the action. Supported values - AlertingAction, LogToMetricAction | 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' (required) |
severity | Severity of the alert | '0' '1' '2' '3' '4' (required) |
throttlingInMin | time (in minutes) for which Alerts should be throttled or suppressed. | int |
trigger | The trigger condition that results in the alert rule being. | TriggerCondition (required) |
AzNsActionGroup
Name | Description | Value |
---|---|---|
actionGroup | Azure Action Group reference. | string[] |
customWebhookPayload | Custom payload to be sent for all webhook URI in Azure action group | string |
emailSubject | Custom subject override for all email ids in Azure action group | string |
Criteria
Name | Description | Value |
---|---|---|
dimensions | List of Dimensions for creating metric | Dimension[] |
metricName | Name of the metric | string (required) |
Dimension
Name | Description | Value |
---|---|---|
name | Name of the dimension | string (required) |
operator | Operator for dimension values | 'Include' (required) |
values | List of dimension values | string[] (required) |
LogMetricTrigger
Name | Description | Value |
---|---|---|
metricColumn | Evaluation of metric on a particular column | string |
metricTriggerType | Metric Trigger Type - 'Consecutive' or 'Total' | 'Consecutive' 'Total' |
threshold | The threshold of the metric trigger. | int |
thresholdOperator | Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. | 'Equal' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' |
LogSearchRule
Name | Description | Value |
---|---|---|
action | Action needs to be taken on rule execution. | Action (required) |
autoMitigate | The flag that indicates whether the alert should be automatically resolved or not. The default is false. | bool |
description | The description of the Log Search rule. | string |
displayName | The display name of the alert rule | string |
enabled | The flag which indicates whether the Log Search rule is enabled. Value should be true or false | 'false' 'true' |
schedule | Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction | Schedule |
source | Data Source against which rule will Query Data | Source (required) |
LogToMetricAction
Name | Description | Value |
---|---|---|
criteria | Criteria of Metric | Criteria[] (required) |
odata.type | Specifies the action. Supported values - AlertingAction, LogToMetricAction | 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' (required) |
Microsoft.Insights/scheduledQueryRules
Name | Description | Value |
---|---|---|
location | Resource location | string (required) |
name | The resource name | string (required) |
properties | The rule properties of the resource. | LogSearchRule (required) |
tags | Resource tags | Dictionary of tag names and values. |
type | The resource type | "Microsoft.Insights/scheduledQueryRules@2018-04-16" |
ResourceTags
Name | Description | Value |
---|
Schedule
Name | Description | Value |
---|---|---|
frequencyInMinutes | frequency (in minutes) at which rule condition should be evaluated. | int (required) |
timeWindowInMinutes | Time window for which data needs to be fetched for query (should be greater than or equal to frequencyInMinutes). | int (required) |
Source
Name | Description | Value |
---|---|---|
authorizedResources | List of Resource referred into query | string[] |
dataSourceId | The resource uri over which log search query is to be run. | string (required) |
query | Log search query. Required for action type - AlertingAction | string |
queryType | Set value to 'ResultCount' . | 'ResultCount' |
TriggerCondition
Name | Description | Value |
---|---|---|
metricTrigger | Trigger condition for metric query rule | LogMetricTrigger |
threshold | Result or count threshold based on which rule should be triggered. | int (required) |
thresholdOperator | Evaluation operation for rule - 'GreaterThan' or 'LessThan. | 'Equal' 'GreaterThan' 'GreaterThanOrEqual' 'LessThan' 'LessThanOrEqual' (required) |
Usage Examples
Azure Verified Modules
The following Azure Verified Modules can be used to deploy this resource type.
Module | Description |
---|---|
Scheduled Query Rule | AVM Resource Module for Scheduled Query Rule |