Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alert log templates for ARM and Bicep #527

Merged
merged 4 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tooling/generate-templates/policy/log.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
"resources": [
{
"type": "Microsoft.Insights/scheduledQueryRules",
"apiVersion": "2022-08-01-preview",
"apiVersion": "2022-06-15",
"name": "[[concat(subscription().displayName, '-##ALERT_NAME##')]",
"location": "[[parameters('alertResourceGroupLocation')]",
"identity": {
Expand Down
29 changes: 21 additions & 8 deletions tooling/generate-templates/templates/arm/log.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for the alert."
}
},
"alertName": {
"type": "string",
"minLength": 1,
Expand Down Expand Up @@ -37,22 +44,28 @@
"description": "Full Resource ID of the resource emitting the metric that will be used for the comparison. For example /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroups/ResourceGroupName/providers/Microsoft.compute/virtualMachines/VM_xyz"
}
},
/* Removing muteActionsDuration and defaulting autoMitigate to true
"muteActionsDuration": {
"type": "string",
"allowedValues": [
"PT1M",
"PT5M",
"PT10M",
"PT15M",
"PT30M",
"PT45M",
"PT1H",
"PT2H",
"PT3H",
"PT4H",
"PT5H",
"PT6H",
"PT12H",
"PT24H"
"P1D",
"P2D"
],
"metadata": {
"description": "Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired."
}
},
}, */
"alertSeverity": {
"type": "int",
"defaultValue": ##SEVERITY##,
Expand All @@ -69,7 +82,7 @@
},
"autoMitigate": {
"type": "bool",
"defaultValue": ##AUTO_MITIGATE##,
"defaultValue": true,
"metadata": {
"description": "Specifies whether the alert will automatically resolve"
}
Expand Down Expand Up @@ -215,9 +228,9 @@
"resources": [
{
"type": "Microsoft.Insights/scheduledQueryRules",
"apiVersion": "2021-08-01",
"apiVersion": "2022-06-15",
"name": "[parameters('alertName')]",
"location": "[resourceGroup().location]",
"location": "[parameters('location')]",
"tags": {
"_deployed_by_amba": true
},
Expand Down Expand Up @@ -247,7 +260,7 @@
}
]
},
"muteActionsDuration": "[parameters('muteActionsDuration')]",
//"muteActionsDuration": "[parameters('muteActionsDuration')]",
"autoMitigate": "[parameters('autoMitigate')]",
"checkWorkspaceAlertsStorageConfigured": "[parameters('checkWorkspaceAlertsStorageConfigured')]"
}
Expand Down
15 changes: 10 additions & 5 deletions tooling/generate-templates/templates/bicep/log.bicep
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@description('Location for the alert.')
@minLength(1)
param location string = resourceGroup().location

@description('Name of the alert')
@minLength(1)
param alertName string
Expand All @@ -15,6 +19,7 @@ param checkWorkspaceAlertsStorageConfigured bool = false
@minLength(1)
param resourceId string

/* Removing muteActionsDuration and defaulting autoMitigate to true
@description('Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired.')
@allowed([
'PT1M'
Expand All @@ -26,7 +31,7 @@ param resourceId string
'PT12H'
'PT24H'
])
param muteActionsDuration string
param muteActionsDuration string */

@description('Severity of alert {0,1,2,3,4}')
@allowed([
Expand All @@ -39,7 +44,7 @@ param muteActionsDuration string
param alertSeverity int = ##SEVERITY##

@description('Specifies whether the alert will automatically resolve')
param autoMitigate bool = ##AUTO_MITIGATE##
param autoMitigate bool = true

@description('Name of the metric used in the comparison to activate the alert.')
@minLength(1)
Expand Down Expand Up @@ -127,9 +132,9 @@ param currentDateTimeUtcNow string = utcNow()
])
param telemetryOptOut string = 'No'

resource alert 'Microsoft.Insights/scheduledQueryRules@2021-08-01' = {
resource alert 'Microsoft.Insights/scheduledQueryRules@2022-06-15' = {
name: alertName
location: resourceGroup().location
location: location
tags: {
_deployed_by_amba: 'true'
}
Expand Down Expand Up @@ -159,7 +164,7 @@ resource alert 'Microsoft.Insights/scheduledQueryRules@2021-08-01' = {
}
]
}
muteActionsDuration: muteActionsDuration
//muteActionsDuration: muteActionsDuration
autoMitigate: autoMitigate
checkWorkspaceAlertsStorageConfigured: checkWorkspaceAlertsStorageConfigured
}
Expand Down