Skip to content

Commit

Permalink
Refactor alert templates to use resource group location and streamlin…
Browse files Browse the repository at this point in the history
…e dimensions formatting
  • Loading branch information
JoeyBarnes committed Nov 22, 2024
1 parent b5c8353 commit 1532aed
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 26 deletions.
13 changes: 2 additions & 11 deletions tooling/generate-templates/templates/arm/log.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@
"description": "Name of the alert"
}
},
"location": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Location of the alert"
}
},
"alertDescription": {
"type": "string",
"defaultValue": "##DESCRIPTION##",
Expand Down Expand Up @@ -210,7 +203,7 @@
"type": "Microsoft.Insights/scheduledQueryRules",
"apiVersion": "2021-08-01",
"name": "[parameters('alertName')]",
"location": "[parameters('location')]",
"location": "[resourceGroup().location]",
"tags": {
"_deployed_by_amba": true
},
Expand All @@ -229,9 +222,7 @@
"query": "[parameters('query')]",
"metricMeasureColumn": "[parameters('metricMeasureColumn')]",
"resourceIdColumn": "[parameters('resourceIdColumn')]",
"dimensions": [
##DIMENSIONS##
],
"dimensions": ##DIMENSIONS##,
"operator": "[parameters('operator')]",
"threshold": "[parameters('threshold')]",
"timeAggregation": "[parameters('timeAggregation')]",
Expand Down
4 changes: 1 addition & 3 deletions tooling/generate-templates/templates/arm/metric-dynamic.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@
"criterionType": "DynamicThresholdCriterion",
"name": "1st criterion",
"metricName": "##METRIC_NAME##",
"dimensions": [
##DIMENSIONS##
],
"dimensions": ##DIMENSIONS##,
"operator": "[parameters('operator')]",
"alertSensitivity": "[parameters('alertSensitivity')]",
"failingPeriods": {
Expand Down
4 changes: 1 addition & 3 deletions tooling/generate-templates/templates/arm/metric-static.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@
{
"name": "1st criterion",
"metricName": "##METRIC_NAME##",
"dimensions": [
##DIMENSIONS##
],
"dimensions": ##DIMENSIONS##,
"operator": "[parameters('operator')]",
"threshold": "[parameters('threshold')]",
"timeAggregation": "[parameters('timeAggregation')]",
Expand Down
9 changes: 2 additions & 7 deletions tooling/generate-templates/templates/bicep/log.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
@minLength(1)
param alertName string

@description('Location of the alert')
@minLength(1)
param location string

@description('Description of alert')
param alertDescription string = '##DESCRIPTION##'

Expand Down Expand Up @@ -119,7 +115,7 @@ param telemetryOptOut string = 'No'

resource alert 'Microsoft.Insights/scheduledQueryRules@2021-08-01' = {
name: alertName
location: location
location: resourceGroup().location
tags: {
_deployed_by_amba: 'true'
}
Expand All @@ -138,8 +134,7 @@ resource alert 'Microsoft.Insights/scheduledQueryRules@2021-08-01' = {
query: query
metricMeasureColumn: metricMeasureColumn
resourceIdColumn: resourceIdColumn
dimensions: [##DIMENSIONS##
]
dimensions: [##DIMENSIONS##]
operator: operator
threshold: threshold
timeAggregation: timeAggregation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
criterionType: 'DynamicThresholdCriterion'
name: '1st criterion'
metricName: '##METRIC_NAME##'
dimensions: ##DIMENSIONS##
dimensions: [##DIMENSIONS##]
operator: operator
alertSensitivity: alertSensitivity
failingPeriods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
{
name: '1st criterion'
metricName: '##METRIC_NAME##'
dimensions: ##DIMENSIONS##
dimensions: [##DIMENSIONS##]
operator: operator
threshold: threshold
timeAggregation: timeAggregation
Expand Down

0 comments on commit 1532aed

Please sign in to comment.