I have faced an issue where ARM template cannot parse the query I'm trying to pass when I try to deploy my custom log alert.
Error:
Can someone show me how to avoid this ? I tried to escape the characters, hardcode it into the template, but that doesn't seem to work.
Here is the template resource I'm using:
{
"type": "Microsoft.Insights/scheduledQueryRules",
"name": "Sample log query alert",
"apiVersion": "2018-04-16",
"location": "global",
"properties": {
"description": "[parameters('alertDescription')]",
"enabled": "[parameters('isEnabled')]",
"source": {
"query": "requests | project timestamp, operation_Name, success, cloud_RoleName | where timestamp > ago(5m) | where cloud_RoleName =~ 'appName' and operation_Name =~ 'functionName' and success == false",
"dataSourceId": "[resourceId('Microsoft.insights/components',parameters('applicationInsightsName'))]",
"queryType": "ResultCount"
},
"schedule": {
"frequencyInMinutes": 1,
"timeWindowInMinutes": 5
},
"action": {
"odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction",
"severity": "[parameters('alertSeverity')]",
"aznsAction": {
"actionGroup": [
"[resourceId('Microsoft.Insights/actionGroups',parameters('actionGroupName'))]"
]
}
},
"trigger": {
"thresholdOperator": "GreaterThan",
"threshold": 0
}
}
}
Here is the query I'm trying to use with:
requests | project timestamp, operation_Name, success, cloud_RoleName | where timestamp > ago(5m) | where cloud_RoleName =~ 'appName' and operation_Name =~ 'functionName' and success == false