question

ThangavelDanielTamilarasan-6106 avatar image
0 Votes"
ThangavelDanielTamilarasan-6106 asked stan answered

Microsoft.Insights/scheduledQueryRules: Include Email Subject & Email body

I have the following template , how to add email subject and email body property in this ?

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"type": "string",
"metadata": {
"description": "Name of the alert"
}
},
"location": {
"type": "string",
"metadata": {
"description": "description"
}
},
"alertDescription": {
"type": "string",
"defaultValue": "This is a metric alert",
"metadata": {
"description": "Description of alert"
}
},
"alertSeverity": {
"type": "int",
"defaultValue": 3,
"allowedValues": [
0,
1,
2,
3,
4
],
"metadata": {
"description": "Severity of alert {0,1,2,3,4}"
}
},
"isEnabled": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "Specifies whether the alert is enabled"
}
},
"resourceId": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Resource ID of the resource emitting the metric that will be used for the comparison."
}
},
"criterion": {
"type": "object",
"metadata": {
"description": "Criterion includes metric name, dimension values, threshold and an operator."
}
},
"windowSize": {
"type": "string",
"defaultValue": "PT5M",
"allowedValues": [
"PT5M",
"PT15M",
"PT30M",
"PT1H"
],
"metadata": {
"description": "Period of time used to monitor alert activity based on the threshold. Must be between five minutes and one hour. ISO 8601 duration format."
}
},
"evaluationFrequency": {
"type": "string",
"defaultValue": "PT5M",
"allowedValues": [
"PT5M",
"PT15M",
"PT30M",
"PT1H"
],
"metadata": {
"description": "how often the metric alert is evaluated represented in ISO 8601 duration format"
}
},
"actionGroupId": {
"type": "array",
"defaultValue": {},
"metadata": {
"description": "The ID of the action group that is triggered when the alert is activated or deactivated"
}
}
},
"variables": {
"criteria": "[array(parameters('criterion'))]"
},
"resources": [
{
"name": "[parameters('alertName')]",
"type": "Microsoft.Insights/scheduledQueryRules",
"apiVersion": "2020-05-01-preview",
"tags": {},
"location": "[parameters('location')]",
"properties": {
"description": "[parameters('alertDescription')]",
"displayName": "string",
"severity": "[parameters('alertSeverity')]",
"enabled": "[parameters('isEnabled')]",
"scopes": [
"[parameters('resourceId')]"
],
"evaluationFrequency": "[parameters('evaluationFrequency')]",
"windowSize": "[parameters('windowSize')]",
"overrideQueryTimeRange": "string",
"targetResourceTypes": [
"string"
],
"criteria": {
"allOf": [
{
"query": "string",
"timeAggregation": "string",
"metricMeasureColumn": "string",
"resourceIdColumn": "string",
"dimensions": [
{
"name": "string",
"operator": "string",
"values": [
"string"
]
}
],
"operator": "string",
"threshold": "number",
"failingPeriods": {
"numberOfEvaluationPeriods": "integer",
"minFailingPeriodsToAlert": "integer"
}
}
]
},
"muteActionsDuration": "string",
"actions": "[parameters('actionGroupId')]"
}
}
]
}

azure-monitor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

stan avatar image
0 Votes"
stan answered

Hi,
Adding e-mail body was never allowed on this API. To be precise there are two versions of this API 2020-05-01-preview and 2018-04-16. Version 2020-05-01-preview represents Log Alert v2 and 2018-04-16 represents Log Alert v1. The APIs although similar they have differences when you create the resource and underneath there are also differences like for example the common alert schema is different. 2018-04-16 had option to override the e-mail subject but that is no longer available in 2020-05-01-preview. Under actions array next to actionGroupId you can add webHookProperties property of type object but where you can add additional static values, but I think those will appear only in webhook payload for action group and not in the e-mail. The workaround to achieve such capability is to send the alert to another automation system (for example logic app) and that one to process the data and send modified e-mail.

Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.