From b5c8353fe5dc7c44b6b74902f17e43817dabd665 Mon Sep 17 00:00:00 2001 From: Joseph Barnes Date: Thu, 21 Nov 2024 22:07:29 -0600 Subject: [PATCH 1/2] Update API version to 2023-07-01 and improve dimensions formatting in ARM and Bicep templates --- .../arm/activity-administrative.json | 95 ------- .../arm/activity-resourcehealth.json | 95 ------- .../arm/activity-servicehealth.json | 91 ------ tooling/generate-templates/arm/log.json | 265 ------------------ .../arm/metric-dynamic.json | 221 --------------- .../generate-templates/arm/metric-static.json | 201 ------------- .../bicep/activity-administrative.bicep | 68 ----- .../bicep/activity-resourcehealth.bicep | 66 ----- .../bicep/activity-servicehealth.bicep | 64 ----- tooling/generate-templates/bicep/log.bicep | 173 ------------ .../bicep/metric-dynamic.bicep | 147 ---------- .../bicep/metric-static.bicep | 135 --------- .../arm/activity-administrative.json | 2 +- .../arm/activity-resourcehealth.json | 2 +- .../templates/arm/activity-servicehealth.json | 2 +- .../generate-templates/templates/arm/log.json | 15 +- .../templates/arm/metric-dynamic.json | 6 +- .../templates/arm/metric-static.json | 6 +- .../bicep/activity-administrative.bicep | 2 +- .../bicep/activity-resourcehealth.bicep | 2 +- .../bicep/activity-servicehealth.bicep | 2 +- .../templates/bicep/log.bicep | 11 +- .../templates/bicep/metric-dynamic.bicep | 4 +- .../templates/bicep/metric-static.bicep | 4 +- 24 files changed, 38 insertions(+), 1641 deletions(-) delete mode 100644 tooling/generate-templates/arm/activity-administrative.json delete mode 100644 tooling/generate-templates/arm/activity-resourcehealth.json delete mode 100644 tooling/generate-templates/arm/activity-servicehealth.json delete mode 100644 tooling/generate-templates/arm/log.json delete mode 100644 tooling/generate-templates/arm/metric-dynamic.json delete mode 100644 tooling/generate-templates/arm/metric-static.json delete mode 100644 tooling/generate-templates/bicep/activity-administrative.bicep delete mode 100644 tooling/generate-templates/bicep/activity-resourcehealth.bicep delete mode 100644 tooling/generate-templates/bicep/activity-servicehealth.bicep delete mode 100644 tooling/generate-templates/bicep/log.bicep delete mode 100644 tooling/generate-templates/bicep/metric-dynamic.bicep delete mode 100644 tooling/generate-templates/bicep/metric-static.bicep diff --git a/tooling/generate-templates/arm/activity-administrative.json b/tooling/generate-templates/arm/activity-administrative.json deleted file mode 100644 index 093e567a2..000000000 --- a/tooling/generate-templates/arm/activity-administrative.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "alertName": { - "type": "string", - "metadata": { - "description": "Unique name (within the Resource Group) for the Activity log alert." - } - }, - "alertDescription": { - "type": "string", - "defaultValue": "##DESCRIPTION##", - "metadata": { - "description": "Description of alert" - } - }, - "isEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Indicates whether or not the alert is enabled." - } - }, - "currentDateTimeUtcNow": { - "type": "string", - "defaultValue": "[utcNow()]", - "metadata": { - "description": "The current date and time using the utcNow function. Used for deployment name uniqueness" - } - }, - "telemetryOptOut": { - "type": "string", - "defaultValue": "No", - "allowedValues": [ - "Yes", - "No" - ], - "metadata": { - "description": "The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry." - } - } - }, - "variables": { - "pidDeploymentName": "[take(concat('##TELEMETRY_PID##-', uniqueString(resourceGroup().id, parameters('alertName'), parameters('currentDateTimeUtcNow'))), 64)]" - }, - "resources": [ - { - "type": "Microsoft.Insights/activityLogAlerts", - "apiVersion": "2017-04-01", - "name": "[parameters('alertName')]", - "location": "Global", - "tags": { - "_deployed_by_amba": true - }, - "properties": { - "description": "[parameters('alertDescription')]", - "scopes": [ - "[subscription().id]" - ], - "enabled": "[parameters('isEnabled')]", - "condition": { - "allOf": [ - { - "field": "category", - "equals": "Administrative" - }, - { - "field": "operationName", - "equals": "##OPERATION_NAME##" - }, - { - "field": "status", - "containsAny": ##STATUS## - } - ] - } - } - }, - { - "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2023-07-01", - "name": "[variables('pidDeploymentName')]", - "type": "Microsoft.Resources/deployments", - "properties": { - "mode": "Incremental", - "template": { - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "resources": [] - } - } - } - ] -} diff --git a/tooling/generate-templates/arm/activity-resourcehealth.json b/tooling/generate-templates/arm/activity-resourcehealth.json deleted file mode 100644 index 9cb698f59..000000000 --- a/tooling/generate-templates/arm/activity-resourcehealth.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "alertName": { - "type": "string", - "metadata": { - "description": "Unique name (within the Resource Group) for the Activity log alert." - } - }, - "alertDescription": { - "type": "string", - "defaultValue": "##DESCRIPTION##", - "metadata": { - "description": "Description of alert" - } - }, - "isEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Indicates whether or not the alert is enabled." - } - }, - "currentDateTimeUtcNow": { - "type": "string", - "defaultValue": "[utcNow()]", - "metadata": { - "description": "The current date and time using the utcNow function. Used for deployment name uniqueness" - } - }, - "telemetryOptOut": { - "type": "string", - "defaultValue": "No", - "allowedValues": [ - "Yes", - "No" - ], - "metadata": { - "description": "The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry." - } - } - }, - "variables": { - "pidDeploymentName": "[take(concat('##TELEMETRY_PID##-', uniqueString(resourceGroup().id, parameters('alertName'), parameters('currentDateTimeUtcNow'))), 64)]" - }, - "resources": [ - { - "type": "Microsoft.Insights/activityLogAlerts", - "apiVersion": "2017-04-01", - "name": "[parameters('alertName')]", - "location": "Global", - "tags": { - "_deployed_by_amba": true - }, - "properties": { - "description": "[parameters('alertDescription')]", - "scopes": [ - "[subscription().id]" - ], - "enabled": "[parameters('isEnabled')]", - "condition": { - "allOf": [ - { - "field": "category", - "equals": "ResourceHealth" - }, - { - "anyOf": [##CAUSES## - ] - }, - { - "anyOf": [##CURRENT_HEALTH_STATUS## - ] - } - ] - } - } - }, - { - "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2023-07-01", - "name": "[variables('pidDeploymentName')]", - "type": "Microsoft.Resources/deployments", - "properties": { - "mode": "Incremental", - "template": { - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "resources": [] - } - } - } - ] -} diff --git a/tooling/generate-templates/arm/activity-servicehealth.json b/tooling/generate-templates/arm/activity-servicehealth.json deleted file mode 100644 index 22f75d9d9..000000000 --- a/tooling/generate-templates/arm/activity-servicehealth.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "alertName": { - "type": "string", - "metadata": { - "description": "Unique name (within the Resource Group) for the Activity log alert." - } - }, - "alertDescription": { - "type": "string", - "defaultValue": "##DESCRIPTION##", - "metadata": { - "description": "Description of alert" - } - }, - "isEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Indicates whether or not the alert is enabled." - } - }, - "currentDateTimeUtcNow": { - "type": "string", - "defaultValue": "[utcNow()]", - "metadata": { - "description": "The current date and time using the utcNow function. Used for deployment name uniqueness" - } - }, - "telemetryOptOut": { - "type": "string", - "defaultValue": "No", - "allowedValues": [ - "Yes", - "No" - ], - "metadata": { - "description": "The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry." - } - } - }, - "variables": { - "pidDeploymentName": "[take(concat('##TELEMETRY_PID-', uniqueString(resourceGroup().id, parameters('alertName'), parameters('currentDateTimeUtcNow'))), 64)]" - }, - "resources": [ - { - "type": "Microsoft.Insights/activityLogAlerts", - "apiVersion": "2017-04-01", - "name": "[parameters('alertName')]", - "location": "Global", - "tags": { - "_deployed_by_amba": true - }, - "properties": { - "description": "[parameters('alertDescription')]", - "scopes": [ - "[subscription().id]" - ], - "enabled": "[parameters('isEnabled')]", - "condition": { - "allOf": [ - { - "field": "category", - "equals": "ServiceHealth" - }, - { - "field": "properties.incidentType", - "equals": "##INCIDENT_TYPE##" - } - ] - } - } - }, - { - "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2023-07-01", - "name": "[variables('pidDeploymentName')]", - "type": "Microsoft.Resources/deployments", - "properties": { - "mode": "Incremental", - "template": { - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "resources": [] - } - } - } - ] -} diff --git a/tooling/generate-templates/arm/log.json b/tooling/generate-templates/arm/log.json deleted file mode 100644 index b3371f4d5..000000000 --- a/tooling/generate-templates/arm/log.json +++ /dev/null @@ -1,265 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "alertName": { - "type": "string", - "minLength": 1, - "metadata": { - "description": "Name of the alert" - } - }, - "location": { - "type": "string", - "minLength": 1, - "metadata": { - "description": "Location of the alert" - } - }, - "alertDescription": { - "type": "string", - "defaultValue": "##DESCRIPTION##", - "metadata": { - "description": "Description of alert" - } - }, - "isEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies whether the alert is enabled" - } - }, - "checkWorkspaceAlertsStorageConfigured": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Specifies whether to check linked storage and fail creation if the storage was not found" - } - }, - "resourceId": { - "type": "string", - "minLength": 1, - "metadata": { - "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" - } - }, - "muteActionsDuration": { - "type": "string", - "allowedValues": [ - "PT1M", - "PT5M", - "PT15M", - "PT30M", - "PT1H", - "PT6H", - "PT12H", - "PT24H" - ], - "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##, - "allowedValues": [ - 0, - 1, - 2, - 3, - 4 - ], - "metadata": { - "description": "Severity of alert {0,1,2,3,4}" - } - }, - "autoMitigate": { - "type": "bool", - "defaultValue": ##AUTO_MITIGATE##, - "metadata": { - "description": "Specifies whether the alert will automatically resolve" - } - }, - "query": { - "type": "string", - "minLength": 1, - "defaultValue": ##QUERY##, - "metadata": { - "description": "Name of the metric used in the comparison to activate the alert." - } - }, - "metricMeasureColumn": { - "type": "string", - "defaultValue": "##METRIC_MEASURE_COLUMN##", - "metadata": { - "description": "Name of the measure column used in the alert evaluation." - } - }, - "resourceIdColumn": { - "type": "string", - "defaultValue": "##RESOURCE_ID_COLUMN##", - "metadata": { - "description": "Name of the resource ID column used in the alert targeting the alerts." - } - }, - "operator": { - "type": "string", - "defaultValue": "##OPERATOR##", - "allowedValues": [ - "Equals", - "GreaterThan", - "GreaterThanOrEqual", - "LessThan", - "LessThanOrEqual" - ], - "metadata": { - "description": "Operator comparing the current value with the threshold value." - } - }, - "threshold": { - "type": "string", - "defaultValue": "##THRESHOLD##", - "metadata": { - "description": "The threshold value at which the alert is activated." - } - }, - "numberOfEvaluationPeriods": { - "type": "int", - "defaultValue": ##FAILING_PERIODS_NUMBER_OF_EVALUATION_PERIODS##, - "metadata": { - "description": "The number of periods to check in the alert evaluation." - } - }, - "minFailingPeriodsToAlert": { - "type": "int", - "defaultValue": ##FAILING_PERIODS_MIN_FAILING_PERIODS_TO_ALERT##, - "metadata": { - "description": "The number of unhealthy periods to alert on (must be lower or equal to numberOfEvaluationPeriods)." - } - }, - "timeAggregation": { - "type": "string", - "defaultValue": "##TIME_AGGREGATION##", - "allowedValues": [ - "Average", - "Minimum", - "Maximum", - "Total", - "Count" - ], - "metadata": { - "description": "How the data that is collected should be combined over time." - } - }, - "windowSize": { - "type": "string", - "defaultValue": "##WINDOW_SIZE##", - "allowedValues": [ - "PT1M", - "PT5M", - "PT15M", - "PT30M", - "PT1H", - "PT6H", - "PT12H", - "PT24H", - "PT1D" - ], - "metadata": { - "description": "Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format." - } - }, - "evaluationFrequency": { - "type": "string", - "defaultValue": "##EVALUATION_FREQUENCY##", - "allowedValues": [ - "PT5M", - "PT15M", - "PT30M", - "PT1H" - ], - "metadata": { - "description": "how often the metric alert is evaluated represented in ISO 8601 duration format" - } - }, - "currentDateTimeUtcNow": { - "type": "string", - "defaultValue": "[utcNow()]", - "metadata": { - "description": "The current date and time using the utcNow function. Used for deployment name uniqueness" - } - }, - "telemetryOptOut": { - "type": "string", - "defaultValue": "No", - "allowedValues": [ - "Yes", - "No" - ], - "metadata": { - "description": "The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry." - } - } - }, - "variables": { - "pidDeploymentName": "[take(concat('##TELEMETRY_PID##-', uniqueString(resourceGroup().id, parameters('alertName'), parameters('currentDateTimeUtcNow'))), 64)]" - }, - "resources": [ - { - "type": "Microsoft.Insights/scheduledQueryRules", - "apiVersion": "2021-08-01", - "name": "[parameters('alertName')]", - "location": "[parameters('location')]", - "tags": { - "_deployed_by_amba": true - }, - "properties": { - "description": "[parameters('alertDescription')]", - "severity": "[parameters('alertSeverity')]", - "enabled": "[parameters('isEnabled')]", - "scopes": [ - "[parameters('resourceId')]" - ], - "evaluationFrequency": "[parameters('evaluationFrequency')]", - "windowSize": "[parameters('windowSize')]", - "criteria": { - "allOf": [ - { - "query": "[parameters('query')]", - "metricMeasureColumn": "[parameters('metricMeasureColumn')]", - "resourceIdColumn": "[parameters('resourceIdColumn')]", - "dimensions": [ - ##DIMENSIONS## - ], - "operator": "[parameters('operator')]", - "threshold": "[parameters('threshold')]", - "timeAggregation": "[parameters('timeAggregation')]", - "failingPeriods": { - "numberOfEvaluationPeriods": "[parameters('numberOfEvaluationPeriods')]", - "minFailingPeriodsToAlert": "[parameters('minFailingPeriodsToAlert')]" - } - } - ] - }, - "muteActionsDuration": "[parameters('muteActionsDuration')]", - "autoMitigate": "[parameters('autoMitigate')]", - "checkWorkspaceAlertsStorageConfigured": "[parameters('checkWorkspaceAlertsStorageConfigured')]" - } - }, - { - "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2023-07-01", - "name": "[variables('pidDeploymentName')]", - "type": "Microsoft.Resources/deployments", - "properties": { - "mode": "Incremental", - "template": { - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "resources": [] - } - } - } - ] -} diff --git a/tooling/generate-templates/arm/metric-dynamic.json b/tooling/generate-templates/arm/metric-dynamic.json deleted file mode 100644 index 28e1cf149..000000000 --- a/tooling/generate-templates/arm/metric-dynamic.json +++ /dev/null @@ -1,221 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "alertName": { - "type": "string", - "minLength": 1, - "metadata": { - "description": "Name of the alert" - } - }, - "alertDescription": { - "type": "string", - "defaultValue": "##DESCRIPTION##", - "metadata": { - "description": "Description of alert" - } - }, - "targetResourceId": { - "type": "string", - "minLength": 1, - "metadata": { - "description": "List of Azure resource Ids seperated by a comma. For example - /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroup/resource-group-name/Microsoft.compute/virtualMachines/vm-name" - } - }, - "targetResourceRegion": { - "type": "string", - "metadata": { - "description": "Azure region in which target resources to be monitored are in (without spaces). For example: EastUS" - } - }, - "targetResourceType": { - "type": "string", - "minLength": 1, - "metadata": { - "description": "Resource type of target resources to be monitored." - } - }, - "isEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies whether the alert is enabled" - } - }, - "alertSeverity": { - "type": "int", - "defaultValue": ##SEVERITY##, - "allowedValues": [ - 0, - 1, - 2, - 3, - 4 - ], - "metadata": { - "description": "Severity of alert {0,1,2,3,4}" - } - }, - "operator": { - "type": "string", - "defaultValue": "##OPERATOR##", - "allowedValues": [ - "GreaterThan", - "LessThan", - "GreaterOrLessThan" - ], - "metadata": { - "description": "Operator comparing the current value with the threshold value." - } - }, - "alertSensitivity": { - "type": "string", - "defaultValue": "##ALERT_SENSITIVITY##", - "allowedValues": [ - "High", - "Medium", - "Low" - ], - "metadata": { - "description": "Tunes how 'noisy' the Dynamic Thresholds alerts will be: 'High' will result in more alerts while 'Low' will result in fewer alerts." - } - }, - "numberOfEvaluationPeriods": { - "type": "int", - "defaultValue": ##FAILING_PERIODS_NUMBER_OF_EVALUATION_PERIODS##, - "metadata": { - "description": "The number of periods to check in the alert evaluation." - } - }, - "minFailingPeriodsToAlert": { - "type": "int", - "defaultValue": ##FAILING_PERIODS_MIN_FAILING_PERIODS_TO_ALERT##, - "metadata": { - "description": "The number of unhealthy periods to alert on (must be lower or equal to numberOfEvaluationPeriods)." - } - }, - "timeAggregation": { - "type": "string", - "defaultValue": "##TIME_AGGREGATION##", - "allowedValues": [ - "Average", - "Minimum", - "Maximum", - "Total", - "Count" - ], - "metadata": { - "description": "How the data that is collected should be combined over time." - } - }, - "windowSize": { - "type": "string", - "defaultValue": "##WINDOW_SIZE##", - "allowedValues": [ - "PT1M", - "PT5M", - "PT15M", - "PT30M", - "PT1H", - "PT6H", - "PT12H", - "PT24H", - "PT1D" - ], - "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": "##EVALUATION_FREQUENCY##", - "allowedValues": [ - "PT5M", - "PT15M", - "PT30M", - "PT1H" - ], - "metadata": { - "description": "how often the metric alert is evaluated represented in ISO 8601 duration format" - } - }, - "currentDateTimeUtcNow": { - "type": "string", - "defaultValue": "[utcNow()]", - "metadata": { - "description": "The current date and time using the utcNow function. Used for deployment name uniqueness" - } - }, - "telemetryOptOut": { - "type": "string", - "defaultValue": "No", - "allowedValues": [ - "Yes", - "No" - ], - "metadata": { - "description": "The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry." - } - } - }, - "variables": { - "pidDeploymentName": "[take(concat('##TELEMETRY_PID##-', uniqueString(resourceGroup().id, parameters('alertName'), parameters('currentDateTimeUtcNow'))), 64)]", - "varTargetResourceId": "[split(parameters('targetResourceId'), ',')]" - }, - "resources": [ - { - "type": "Microsoft.Insights/metricAlerts", - "apiVersion": "2018-03-01", - "name": "[parameters('alertName')]", - "location": "global", - "tags": { - "_deployed_by_amba": true - }, - "properties": { - "description": "[parameters('alertDescription')]", - "scopes": "[variables('varTargetResourceId')]", - "targetResourceType": "[parameters('targetResourceType')]", - "targetResourceRegion": "[parameters('targetResourceRegion')]", - "severity": "[parameters('alertSeverity')]", - "enabled": "[parameters('isEnabled')]", - "evaluationFrequency": "[parameters('evaluationFrequency')]", - "windowSize": "[parameters('windowSize')]", - "criteria": { - "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", - "allOf": [ - { - "criterionType": "DynamicThresholdCriterion", - "name": "1st criterion", - "metricName": "##METRIC_NAME##", - "dimensions": [ - ##DIMENSIONS## - ], - "operator": "[parameters('operator')]", - "alertSensitivity": "[parameters('alertSensitivity')]", - "failingPeriods": { - "numberOfEvaluationPeriods": "[parameters('numberOfEvaluationPeriods')]", - "minFailingPeriodsToAlert": "[parameters('minFailingPeriodsToAlert')]" - }, - "timeAggregation": "[parameters('timeAggregation')]" - } - ] - } - } - }, - { - "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2023-07-01", - "name": "[variables('pidDeploymentName')]", - "type": "Microsoft.Resources/deployments", - "properties": { - "mode": "Incremental", - "template": { - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "resources": [] - } - } - } - ] -} diff --git a/tooling/generate-templates/arm/metric-static.json b/tooling/generate-templates/arm/metric-static.json deleted file mode 100644 index 73a780eb0..000000000 --- a/tooling/generate-templates/arm/metric-static.json +++ /dev/null @@ -1,201 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "alertName": { - "type": "string", - "minLength": 1, - "metadata": { - "description": "Name of the alert" - } - }, - "alertDescription": { - "type": "string", - "defaultValue": "##DESCRIPTION##", - "metadata": { - "description": "Description of alert" - } - }, - "targetResourceId": { - "type": "string", - "minLength": 1, - "metadata": { - "description": "List of Azure resource Ids seperated by a comma. For example - /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroup/resource-group-name/Microsoft.compute/virtualMachines/vm-name" - } - }, - "targetResourceRegion": { - "type": "string", - "metadata": { - "description": "Azure region in which target resources to be monitored are in (without spaces). For example: EastUS" - } - }, - "targetResourceType": { - "type": "string", - "minLength": 1, - "metadata": { - "description": "Resource type of target resources to be monitored." - } - }, - "isEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies whether the alert is enabled" - } - }, - "alertSeverity": { - "type": "int", - "defaultValue": ##SEVERITY##, - "allowedValues": [ - 0, - 1, - 2, - 3, - 4 - ], - "metadata": { - "description": "Severity of alert {0,1,2,3,4}" - } - }, - "operator": { - "type": "string", - "defaultValue": "##OPERATOR##", - "allowedValues": [ - "Equals", - "GreaterThan", - "GreaterThanOrEqual", - "LessThan", - "LessThanOrEqual" - ], - "metadata": { - "description": "Operator comparing the current value with the threshold value." - } - }, - "threshold": { - "type": "string", - "defaultValue": "##THRESHOLD##", - "metadata": { - "description": "The threshold value at which the alert is activated." - } - }, - "timeAggregation": { - "type": "string", - "defaultValue": "##TIME_AGGREGATION##", - "allowedValues": [ - "Average", - "Minimum", - "Maximum", - "Total", - "Count" - ], - "metadata": { - "description": "How the data that is collected should be combined over time." - } - }, - "windowSize": { - "type": "string", - "defaultValue": "##WINDOW_SIZE##", - "allowedValues": [ - "PT1M", - "PT5M", - "PT15M", - "PT30M", - "PT1H", - "PT6H", - "PT12H", - "PT24H", - "PT1D" - ], - "metadata": { - "description": "Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format." - } - }, - "evaluationFrequency": { - "type": "string", - "defaultValue": "##EVALUATION_FREQUENCY##", - "allowedValues": [ - "PT1M", - "PT5M", - "PT15M", - "PT30M", - "PT1H" - ], - "metadata": { - "description": "how often the metric alert is evaluated represented in ISO 8601 duration format" - } - }, - "currentDateTimeUtcNow": { - "type": "string", - "defaultValue": "[utcNow()]", - "metadata": { - "description": "The current date and time using the utcNow function. Used for deployment name uniqueness" - } - }, - "telemetryOptOut": { - "type": "string", - "defaultValue": "No", - "allowedValues": [ - "Yes", - "No" - ], - "metadata": { - "description": "The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry." - } - } - }, - "variables": { - "pidDeploymentName": "[take(concat('##TELEMETRY_PID##-', uniqueString(resourceGroup().id, parameters('alertName'), parameters('currentDateTimeUtcNow'))), 64)]", - "varTargetResourceId": "[split(parameters('targetResourceId'), ',')]" - }, - "resources": [ - { - "type": "Microsoft.Insights/metricAlerts", - "apiVersion": "2018-03-01", - "name": "[parameters('alertName')]", - "location": "global", - "tags": { - "_deployed_by_amba": true - }, - "properties": { - "description": "[parameters('alertDescription')]", - "scopes": "[variables('varTargetResourceId')]", - "targetResourceType": "[parameters('targetResourceType')]", - "targetResourceRegion": "[parameters('targetResourceRegion')]", - "severity": "[parameters('alertSeverity')]", - "enabled": "[parameters('isEnabled')]", - "evaluationFrequency": "[parameters('evaluationFrequency')]", - "windowSize": "[parameters('windowSize')]", - "criteria": { - "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", - "allOf": [ - { - "name": "1st criterion", - "metricName": "##METRIC_NAME##", - "dimensions": [ - ##DIMENSIONS## - ], - "operator": "[parameters('operator')]", - "threshold": "[parameters('threshold')]", - "timeAggregation": "[parameters('timeAggregation')]", - "criterionType": "StaticThresholdCriterion" - } - ] - } - } - }, - { - "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2023-07-01", - "name": "[variables('pidDeploymentName')]", - "type": "Microsoft.Resources/deployments", - "properties": { - "mode": "Incremental", - "template": { - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "resources": [] - } - } - } - ] -} diff --git a/tooling/generate-templates/bicep/activity-administrative.bicep b/tooling/generate-templates/bicep/activity-administrative.bicep deleted file mode 100644 index 29dc89f42..000000000 --- a/tooling/generate-templates/bicep/activity-administrative.bicep +++ /dev/null @@ -1,68 +0,0 @@ -@description('Unique name (within the Resource Group) for the Activity log alert.') -@minLength(1) -param alertName string - -@description('Description of alert') -param alertDescription string = '##DESCRIPTION##' - -@description('Indicates whether or not the alert is enabled.') -param isEnabled bool = true - -@description('"The current date and time using the utcNow function. Used for deployment name uniqueness') -param currentDateTimeUtcNow string = utcNow() - -@description('The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry.') -@allowed([ - 'Yes' - 'No' -]) -param telemetryOptOut string = 'No' - -resource symbolicname 'Microsoft.Insights/activityLogAlerts@2023-01-01-preview' = { - name: alertName - location: 'Global' - tags: { - _deployed_by_amba: 'true' - } - properties: { - description: alertDescription - scopes: [ - subscription().id - ] - enabled: isEnabled - condition: { - allOf: [ - { - { - field: 'category' - equals: 'Administrative' - } - { - field: 'operationName' - equals: '##OPERATION_NAME##' - } - { - field: 'status' - containsAny: ##STATUS## - } - } - ] - } - } -} - -var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { - name: ambaTelemetryPidName - tags: { - _deployed_by_amba: 'true' - } - properties: { - mode: 'Incremental' - template: { - '$schema': 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#' - contentVersion: '1.0.0.0' - resources: [] - } - } -} diff --git a/tooling/generate-templates/bicep/activity-resourcehealth.bicep b/tooling/generate-templates/bicep/activity-resourcehealth.bicep deleted file mode 100644 index 24d1c410b..000000000 --- a/tooling/generate-templates/bicep/activity-resourcehealth.bicep +++ /dev/null @@ -1,66 +0,0 @@ -@description('Unique name (within the Resource Group) for the Activity log alert.') -@minLength(1) -param alertName string - -@description('Description of alert') -param alertDescription string = '##DESCRIPTION##' - -@description('Indicates whether or not the alert is enabled.') -param isEnabled bool = true - -@description('"The current date and time using the utcNow function. Used for deployment name uniqueness') -param currentDateTimeUtcNow string = utcNow() - -@description('The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry.') -@allowed([ - 'Yes' - 'No' -]) -param telemetryOptOut string = 'No' - -resource symbolicname 'Microsoft.Insights/activityLogAlerts@2023-01-01-preview' = { - name: alertName - location: 'Global' - tags: { - _deployed_by_amba: 'true' - } - properties: { - description: alertDescription - scopes: [ - subscription().id - ] - enabled: isEnabled - condition: { - allOf: [ - { - field: 'category' - equals: 'ResourceHealth' - } - { - anyOf: [##CAUSES## - ] - } - { - anyOf: [##CURRENT_HEALTH_STATUS## - ] - } - ] - } - } -} - -var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { - name: ambaTelemetryPidName - tags: { - _deployed_by_amba: 'true' - } - properties: { - mode: 'Incremental' - template: { - '$schema': 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#' - contentVersion: '1.0.0.0' - resources: [] - } - } -} diff --git a/tooling/generate-templates/bicep/activity-servicehealth.bicep b/tooling/generate-templates/bicep/activity-servicehealth.bicep deleted file mode 100644 index 5943c7f90..000000000 --- a/tooling/generate-templates/bicep/activity-servicehealth.bicep +++ /dev/null @@ -1,64 +0,0 @@ -@description('Unique name (within the Resource Group) for the Activity log alert.') -@minLength(1) -param alertName string - -@description('Description of alert') -param alertDescription string = '##DESCRIPTION##' - -@description('Indicates whether or not the alert is enabled.') -param isEnabled bool = true - -@description('"The current date and time using the utcNow function. Used for deployment name uniqueness') -param currentDateTimeUtcNow string = utcNow() - -@description('The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry.') -@allowed([ - 'Yes' - 'No' -]) -param telemetryOptOut string = 'No' - -resource symbolicname 'Microsoft.Insights/activityLogAlerts@2023-01-01-preview' = { - name: alertName - location: 'Global' - tags: { - _deployed_by_amba: 'true' - } - properties: { - description: alertDescription - scopes: [ - subscription().id - ] - enabled: isEnabled - condition: { - allOf: [ - { - { - field: 'category' - equals: 'ServiceHealth' - } - { - field: 'properties.incidentType' - equals: '##INCIDENT_TYPE##' - } - } - ] - } - } -} - -var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { - name: ambaTelemetryPidName - tags: { - _deployed_by_amba: 'true' - } - properties: { - mode: 'Incremental' - template: { - '$schema': 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#' - contentVersion: '1.0.0.0' - resources: [] - } - } -} diff --git a/tooling/generate-templates/bicep/log.bicep b/tooling/generate-templates/bicep/log.bicep deleted file mode 100644 index e154f11bc..000000000 --- a/tooling/generate-templates/bicep/log.bicep +++ /dev/null @@ -1,173 +0,0 @@ -@description('Name of the alert') -@minLength(1) -param alertName string - -@description('Location of the alert') -@minLength(1) -param location string - -@description('Description of alert') -param alertDescription string = '##DESCRIPTION##' - -@description('Specifies whether the alert is enabled') -param isEnabled bool = true - -@description('Specifies whether to check linked storage and fail creation if the storage was not found') -param checkWorkspaceAlertsStorageConfigured bool = false - -@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') -@minLength(1) -param resourceId string - -@description('Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired.') -@allowed([ - 'PT1M' - 'PT5M' - 'PT15M' - 'PT30M' - 'PT1H' - 'PT6H' - 'PT12H' - 'PT24H' -]) -param muteActionsDuration string - -@description('Severity of alert {0,1,2,3,4}') -@allowed([ - 0 - 1 - 2 - 3 - 4 -]) -param alertSeverity int = ##SEVERITY## - -@description('Specifies whether the alert will automatically resolve') -param autoMitigate bool = ##AUTO_MITIGATE## - -@description('Name of the metric used in the comparison to activate the alert.') -@minLength(1) -param query string = '##QUERY##' - -@description('Name of the measure column used in the alert evaluation.') -param metricMeasureColumn string = '##METRIC_MEASURE_COLUMN##' - -@description('Name of the resource ID column used in the alert targeting the alerts.') -param resourceIdColumn string = '##RESOURCE_ID_COLUMN##' - -@description('Operator comparing the current value with the threshold value.') -@allowed([ - 'Equals' - 'GreaterThan' - 'GreaterThanOrEqual' - 'LessThan' - 'LessThanOrEqual' -]) -param operator string = '##OPERATOR##' - -@description('The threshold value at which the alert is activated.') -param threshold int = ##THRESHOLD## - -@description('The number of periods to check in the alert evaluation.') -param numberOfEvaluationPeriods int = ##FAILING_PERIODS_NUMBER_OF_EVALUATION_PERIODS## - -@description('The number of unhealthy periods to alert on (must be lower or equal to numberOfEvaluationPeriods).') -param minFailingPeriodsToAlert int = ##FAILING_PERIODS_MIN_FAILING_PERIODS_TO_ALERT## - -@description('How the data that is collected should be combined over time.') -@allowed([ - 'Average' - 'Minimum' - 'Maximum' - 'Total' - 'Count' -]) -param timeAggregation string = '##TIME_AGGREGATION##' - -@description('Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format.') -@allowed([ - 'PT1M' - 'PT5M' - 'PT15M' - 'PT30M' - 'PT1H' - 'PT6H' - 'PT12H' - 'PT24H' - 'P1D' -]) -param windowSize string = '##WINDOW_SIZE##' - -@description('how often the metric alert is evaluated represented in ISO 8601 duration format') -@allowed([ - 'PT5M' - 'PT15M' - 'PT30M' - 'PT1H' -]) -param evaluationFrequency string = '##EVALUATION_FREQUENCY##' - -@description('"The current date and time using the utcNow function. Used for deployment name uniqueness') -param currentDateTimeUtcNow string = utcNow() - -@description('The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry.') -@allowed([ - 'Yes' - 'No' -]) -param telemetryOptOut string = 'No' - -resource alert 'Microsoft.Insights/scheduledQueryRules@2021-08-01' = { - name: alertName - location: location - tags: { - _deployed_by_amba: 'true' - } - properties: { - description: alertDescription - severity: alertSeverity - enabled: isEnabled - scopes: [ - resourceId - ] - evaluationFrequency: evaluationFrequency - windowSize: windowSize - criteria: { - allOf: [ - { - query: query - metricMeasureColumn: metricMeasureColumn - resourceIdColumn: resourceIdColumn - dimensions: [##DIMENSIONS## - ] - operator: operator - threshold: threshold - timeAggregation: timeAggregation - failingPeriods: { - numberOfEvaluationPeriods: numberOfEvaluationPeriods - minFailingPeriodsToAlert: minFailingPeriodsToAlert - } - } - ] - } - muteActionsDuration: muteActionsDuration - autoMitigate: autoMitigate - checkWorkspaceAlertsStorageConfigured: checkWorkspaceAlertsStorageConfigured - } -} - -var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { - name: ambaTelemetryPidName - tags: { - _deployed_by_amba: 'true' - } - properties: { - mode: 'Incremental' - template: { - '$schema': 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#' - contentVersion: '1.0.0.0' - resources: [] - } - } -} diff --git a/tooling/generate-templates/bicep/metric-dynamic.bicep b/tooling/generate-templates/bicep/metric-dynamic.bicep deleted file mode 100644 index fb68bd096..000000000 --- a/tooling/generate-templates/bicep/metric-dynamic.bicep +++ /dev/null @@ -1,147 +0,0 @@ -@description('Name of the alert') -@minLength(1) -param alertName string - -@description('Description of alert') -param alertDescription string = '##DESCRIPTION##' - -@description('array of Azure resource Ids. For example - /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroup/resource-group-name/Microsoft.compute/virtualMachines/vm-name') -@minLength(1) -param targetResourceId array - -@description('Azure region in which target resources to be monitored are in (without spaces). For example: EastUS') -param targetResourceRegion string - -@description('Resource type of target resources to be monitored.') -@minLength(1) -param targetResourceType string - -@description('Specifies whether the alert is enabled') -param isEnabled bool = true - -@description('Severity of alert {0,1,2,3,4}') -@allowed([ - 0 - 1 - 2 - 3 - 4 -]) -param alertSeverity int = ##SEVERITY## - -@description('Operator comparing the current value with the threshold value.') -@allowed([ - 'GreaterThan' - 'LessThan' - 'GreaterOrLessThan' -]) -param operator string = '##OPERATOR##' - -@description('Tunes how \'noisy\' the Dynamic Thresholds alerts will be: \'High\' will result in more alerts while \'Low\' will result in fewer alerts.') -@allowed([ - 'High' - 'Medium' - 'Low' -]) -param alertSensitivity string = '##ALERT_SENSITIVITY##' - -@description('The number of periods to check in the alert evaluation.') -param numberOfEvaluationPeriods int = ##FAILING_PERIODS_NUMBER_OF_EVALUATION_PERIODS## - -@description('The number of unhealthy periods to alert on (must be lower or equal to numberOfEvaluationPeriods).') -param minFailingPeriodsToAlert int = ##FAILING_PERIODS_MIN_FAILING_PERIODS_TO_ALERT## - -@description('How the data that is collected should be combined over time.') -@allowed([ - 'Average' - 'Minimum' - 'Maximum' - 'Total' - 'Count' -]) -param timeAggregation string = '##TIME_AGGREGATION##' - -@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.') -@allowed([ - 'PT1M' - 'PT5M' - 'PT15M' - 'PT30M' - 'PT1H' - 'PT6H' - 'PT12H' - 'PT24H' - 'P1D' -]) -param windowSize string = '##WINDOW_SIZE##' - -@description('how often the metric alert is evaluated represented in ISO 8601 duration format') -@allowed([ - 'PT5M' - 'PT15M' - 'PT30M' - 'PT1H' -]) -param evaluationFrequency string = '##EVALUATION_FREQUENCY##' - -@description('"The current date and time using the utcNow function. Used for deployment name uniqueness') -param currentDateTimeUtcNow string = utcNow() - -@description('The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry.') -@allowed([ - 'Yes' - 'No' -]) -param telemetryOptOut string = 'No' - -resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = { - name: alertName - location: 'global' - tags: { - _deployed_by_amba: 'true' - } - properties: { - description: alertDescription - scopes: targetResourceId - targetResourceType: targetResourceType - targetResourceRegion: targetResourceRegion - severity: alertSeverity - enabled: isEnabled - evaluationFrequency: evaluationFrequency - windowSize: windowSize - criteria: { - 'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' - allOf: [ - { - criterionType: 'DynamicThresholdCriterion' - name: '1st criterion' - metricName: '##METRIC_NAME##' - dimensions: ##DIMENSIONS## - operator: operator - alertSensitivity: alertSensitivity - failingPeriods: { - numberOfEvaluationPeriods: numberOfEvaluationPeriods - minFailingPeriodsToAlert: minFailingPeriodsToAlert - } - timeAggregation: timeAggregation - } - ] - } - } -} - -var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { - name: ambaTelemetryPidName - tags: { - _deployed_by_amba: 'true' - } - properties: { - mode: 'Incremental' - template: { - '$schema': 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#' - contentVersion: '1.0.0.0' - resources: [] - } - } -} diff --git a/tooling/generate-templates/bicep/metric-static.bicep b/tooling/generate-templates/bicep/metric-static.bicep deleted file mode 100644 index 1258b56af..000000000 --- a/tooling/generate-templates/bicep/metric-static.bicep +++ /dev/null @@ -1,135 +0,0 @@ -@description('Name of the alert') -@minLength(1) -param alertName string - -@description('Description of alert') -param alertDescription string = '##DESCRIPTION##' - -@description('Array of Azure resource Ids. For example - /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroup/resource-group-name/Microsoft.compute/virtualMachines/vm-name') -@minLength(1) -param targetResourceId array - -@description('Azure region in which target resources to be monitored are in (without spaces). For example: EastUS') -param targetResourceRegion string - -@description('Resource type of target resources to be monitored.') -@minLength(1) -param targetResourceType string - -@description('Specifies whether the alert is enabled') -param isEnabled bool = true - -@description('Severity of alert {0,1,2,3,4}') -@allowed([ - 0 - 1 - 2 - 3 - 4 -]) -param alertSeverity int = ##SEVERITY## - -@description('Operator comparing the current value with the threshold value.') -@allowed([ - 'Equals' - 'GreaterThan' - 'GreaterThanOrEqual' - 'LessThan' - 'LessThanOrEqual' -]) -param operator string = '##OPERATOR##' - -@description('The threshold value at which the alert is activated.') -param threshold int = ##THRESHOLD## - -@description('How the data that is collected should be combined over time.') -@allowed([ - 'Average' - 'Minimum' - 'Maximum' - 'Total' - 'Count' -]) -param timeAggregation string = '##TIME_AGGREGATION##' - -@description('Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format.') -@allowed([ - 'PT1M' - 'PT5M' - 'PT15M' - 'PT30M' - 'PT1H' - 'PT6H' - 'PT12H' - 'PT24H' - 'P1D' -]) -param windowSize string = '##WINDOW_SIZE##' - -@description('how often the metric alert is evaluated represented in ISO 8601 duration format') -@allowed([ - 'PT1M' - 'PT5M' - 'PT15M' - 'PT30M' - 'PT1H' -]) -param evaluationFrequency string = '##EVALUATION_FREQUENCY##' - -@description('"The current date and time using the utcNow function. Used for deployment name uniqueness') -param currentDateTimeUtcNow string = utcNow() - -@description('The customer usage identifier used for telemetry purposes. The default value of False enables telemetry. The value of True disables telemetry.') -@allowed([ - 'Yes' - 'No' -]) -param telemetryOptOut string = 'No' - -resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = { - name: alertName - location: 'global' - tags: { - _deployed_by_amba: 'true' - } - properties: { - description: alertDescription - scopes: targetResourceId - targetResourceType: targetResourceType - targetResourceRegion: targetResourceRegion - severity: alertSeverity - enabled: isEnabled - evaluationFrequency: evaluationFrequency - windowSize: windowSize - criteria: { - 'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' - allOf: [ - { - name: '1st criterion' - metricName: '##METRIC_NAME##' - dimensions: ##DIMENSIONS## - operator: operator - threshold: threshold - timeAggregation: timeAggregation - criterionType: 'StaticThresholdCriterion' - } - ] - } - } -} - -var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { - name: ambaTelemetryPidName - tags: { - _deployed_by_amba: 'true' - } - properties: { - mode: 'Incremental' - template: { - '$schema': 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#' - contentVersion: '1.0.0.0' - resources: [] - } - } -} diff --git a/tooling/generate-templates/templates/arm/activity-administrative.json b/tooling/generate-templates/templates/arm/activity-administrative.json index a48293408..093e567a2 100644 --- a/tooling/generate-templates/templates/arm/activity-administrative.json +++ b/tooling/generate-templates/templates/arm/activity-administrative.json @@ -79,7 +79,7 @@ }, { "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2020-06-01", + "apiVersion": "2023-07-01", "name": "[variables('pidDeploymentName')]", "type": "Microsoft.Resources/deployments", "properties": { diff --git a/tooling/generate-templates/templates/arm/activity-resourcehealth.json b/tooling/generate-templates/templates/arm/activity-resourcehealth.json index a25574c0f..9cb698f59 100644 --- a/tooling/generate-templates/templates/arm/activity-resourcehealth.json +++ b/tooling/generate-templates/templates/arm/activity-resourcehealth.json @@ -79,7 +79,7 @@ }, { "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2020-06-01", + "apiVersion": "2023-07-01", "name": "[variables('pidDeploymentName')]", "type": "Microsoft.Resources/deployments", "properties": { diff --git a/tooling/generate-templates/templates/arm/activity-servicehealth.json b/tooling/generate-templates/templates/arm/activity-servicehealth.json index 796bd3784..22f75d9d9 100644 --- a/tooling/generate-templates/templates/arm/activity-servicehealth.json +++ b/tooling/generate-templates/templates/arm/activity-servicehealth.json @@ -75,7 +75,7 @@ }, { "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2020-06-01", + "apiVersion": "2023-07-01", "name": "[variables('pidDeploymentName')]", "type": "Microsoft.Resources/deployments", "properties": { diff --git a/tooling/generate-templates/templates/arm/log.json b/tooling/generate-templates/templates/arm/log.json index c2a583ca8..b3371f4d5 100644 --- a/tooling/generate-templates/templates/arm/log.json +++ b/tooling/generate-templates/templates/arm/log.json @@ -9,6 +9,13 @@ "description": "Name of the alert" } }, + "location": { + "type": "string", + "minLength": 1, + "metadata": { + "description": "Location of the alert" + } + }, "alertDescription": { "type": "string", "defaultValue": "##DESCRIPTION##", @@ -203,7 +210,7 @@ "type": "Microsoft.Insights/scheduledQueryRules", "apiVersion": "2021-08-01", "name": "[parameters('alertName')]", - "location": "[resourceGroup().location]", + "location": "[parameters('location')]", "tags": { "_deployed_by_amba": true }, @@ -222,7 +229,9 @@ "query": "[parameters('query')]", "metricMeasureColumn": "[parameters('metricMeasureColumn')]", "resourceIdColumn": "[parameters('resourceIdColumn')]", - "dimensions": ##DIMENSIONS##, + "dimensions": [ + ##DIMENSIONS## + ], "operator": "[parameters('operator')]", "threshold": "[parameters('threshold')]", "timeAggregation": "[parameters('timeAggregation')]", @@ -240,7 +249,7 @@ }, { "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2020-06-01", + "apiVersion": "2023-07-01", "name": "[variables('pidDeploymentName')]", "type": "Microsoft.Resources/deployments", "properties": { diff --git a/tooling/generate-templates/templates/arm/metric-dynamic.json b/tooling/generate-templates/templates/arm/metric-dynamic.json index f7184178f..28e1cf149 100644 --- a/tooling/generate-templates/templates/arm/metric-dynamic.json +++ b/tooling/generate-templates/templates/arm/metric-dynamic.json @@ -188,7 +188,9 @@ "criterionType": "DynamicThresholdCriterion", "name": "1st criterion", "metricName": "##METRIC_NAME##", - "dimensions": ##DIMENSIONS##, + "dimensions": [ + ##DIMENSIONS## + ], "operator": "[parameters('operator')]", "alertSensitivity": "[parameters('alertSensitivity')]", "failingPeriods": { @@ -203,7 +205,7 @@ }, { "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2020-06-01", + "apiVersion": "2023-07-01", "name": "[variables('pidDeploymentName')]", "type": "Microsoft.Resources/deployments", "properties": { diff --git a/tooling/generate-templates/templates/arm/metric-static.json b/tooling/generate-templates/templates/arm/metric-static.json index 01d14e539..73a780eb0 100644 --- a/tooling/generate-templates/templates/arm/metric-static.json +++ b/tooling/generate-templates/templates/arm/metric-static.json @@ -171,7 +171,9 @@ { "name": "1st criterion", "metricName": "##METRIC_NAME##", - "dimensions": ##DIMENSIONS##, + "dimensions": [ + ##DIMENSIONS## + ], "operator": "[parameters('operator')]", "threshold": "[parameters('threshold')]", "timeAggregation": "[parameters('timeAggregation')]", @@ -183,7 +185,7 @@ }, { "condition": "[equals(parameters('telemetryOptOut'), 'No')]", - "apiVersion": "2020-06-01", + "apiVersion": "2023-07-01", "name": "[variables('pidDeploymentName')]", "type": "Microsoft.Resources/deployments", "properties": { diff --git a/tooling/generate-templates/templates/bicep/activity-administrative.bicep b/tooling/generate-templates/templates/bicep/activity-administrative.bicep index 53c404616..29dc89f42 100644 --- a/tooling/generate-templates/templates/bicep/activity-administrative.bicep +++ b/tooling/generate-templates/templates/bicep/activity-administrative.bicep @@ -52,7 +52,7 @@ resource symbolicname 'Microsoft.Insights/activityLogAlerts@2023-01-01-preview' } var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2020-06-01' = if (telemetryOptOut == 'No') { +resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { name: ambaTelemetryPidName tags: { _deployed_by_amba: 'true' diff --git a/tooling/generate-templates/templates/bicep/activity-resourcehealth.bicep b/tooling/generate-templates/templates/bicep/activity-resourcehealth.bicep index e993691b9..24d1c410b 100644 --- a/tooling/generate-templates/templates/bicep/activity-resourcehealth.bicep +++ b/tooling/generate-templates/templates/bicep/activity-resourcehealth.bicep @@ -50,7 +50,7 @@ resource symbolicname 'Microsoft.Insights/activityLogAlerts@2023-01-01-preview' } var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2020-06-01' = if (telemetryOptOut == 'No') { +resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { name: ambaTelemetryPidName tags: { _deployed_by_amba: 'true' diff --git a/tooling/generate-templates/templates/bicep/activity-servicehealth.bicep b/tooling/generate-templates/templates/bicep/activity-servicehealth.bicep index 36e9470f7..5943c7f90 100644 --- a/tooling/generate-templates/templates/bicep/activity-servicehealth.bicep +++ b/tooling/generate-templates/templates/bicep/activity-servicehealth.bicep @@ -48,7 +48,7 @@ resource symbolicname 'Microsoft.Insights/activityLogAlerts@2023-01-01-preview' } var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2020-06-01' = if (telemetryOptOut == 'No') { +resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { name: ambaTelemetryPidName tags: { _deployed_by_amba: 'true' diff --git a/tooling/generate-templates/templates/bicep/log.bicep b/tooling/generate-templates/templates/bicep/log.bicep index 7387bc999..e154f11bc 100644 --- a/tooling/generate-templates/templates/bicep/log.bicep +++ b/tooling/generate-templates/templates/bicep/log.bicep @@ -2,6 +2,10 @@ @minLength(1) param alertName string +@description('Location of the alert') +@minLength(1) +param location string + @description('Description of alert') param alertDescription string = '##DESCRIPTION##' @@ -115,7 +119,7 @@ param telemetryOptOut string = 'No' resource alert 'Microsoft.Insights/scheduledQueryRules@2021-08-01' = { name: alertName - location: resourceGroup().location + location: location tags: { _deployed_by_amba: 'true' } @@ -134,7 +138,8 @@ resource alert 'Microsoft.Insights/scheduledQueryRules@2021-08-01' = { query: query metricMeasureColumn: metricMeasureColumn resourceIdColumn: resourceIdColumn - dimensions: [##DIMENSIONS##] + dimensions: [##DIMENSIONS## + ] operator: operator threshold: threshold timeAggregation: timeAggregation @@ -152,7 +157,7 @@ resource alert 'Microsoft.Insights/scheduledQueryRules@2021-08-01' = { } var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2020-06-01' = if (telemetryOptOut == 'No') { +resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { name: ambaTelemetryPidName tags: { _deployed_by_amba: 'true' diff --git a/tooling/generate-templates/templates/bicep/metric-dynamic.bicep b/tooling/generate-templates/templates/bicep/metric-dynamic.bicep index 77a4a28da..fb68bd096 100644 --- a/tooling/generate-templates/templates/bicep/metric-dynamic.bicep +++ b/tooling/generate-templates/templates/bicep/metric-dynamic.bicep @@ -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: { @@ -131,7 +131,7 @@ resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = { } var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2020-06-01' = if (telemetryOptOut == 'No') { +resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { name: ambaTelemetryPidName tags: { _deployed_by_amba: 'true' diff --git a/tooling/generate-templates/templates/bicep/metric-static.bicep b/tooling/generate-templates/templates/bicep/metric-static.bicep index b4511d07d..1258b56af 100644 --- a/tooling/generate-templates/templates/bicep/metric-static.bicep +++ b/tooling/generate-templates/templates/bicep/metric-static.bicep @@ -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 @@ -119,7 +119,7 @@ resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = { } var ambaTelemetryPidName = '##TELEMETRY_PID##-${uniqueString(resourceGroup().id, alertName, currentDateTimeUtcNow)}' -resource ambaTelemetryPid 'Microsoft.Resources/deployments@2020-06-01' = if (telemetryOptOut == 'No') { +resource ambaTelemetryPid 'Microsoft.Resources/deployments@2023-07-01' = if (telemetryOptOut == 'No') { name: ambaTelemetryPidName tags: { _deployed_by_amba: 'true' From 1532aed682b4c429d7f2d50fe69f4ce5f66203b5 Mon Sep 17 00:00:00 2001 From: Joseph Barnes Date: Thu, 21 Nov 2024 22:20:36 -0600 Subject: [PATCH 2/2] Refactor alert templates to use resource group location and streamline dimensions formatting --- tooling/generate-templates/templates/arm/log.json | 13 ++----------- .../templates/arm/metric-dynamic.json | 4 +--- .../templates/arm/metric-static.json | 4 +--- .../generate-templates/templates/bicep/log.bicep | 9 ++------- .../templates/bicep/metric-dynamic.bicep | 2 +- .../templates/bicep/metric-static.bicep | 2 +- 6 files changed, 8 insertions(+), 26 deletions(-) diff --git a/tooling/generate-templates/templates/arm/log.json b/tooling/generate-templates/templates/arm/log.json index b3371f4d5..36f95f5af 100644 --- a/tooling/generate-templates/templates/arm/log.json +++ b/tooling/generate-templates/templates/arm/log.json @@ -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##", @@ -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 }, @@ -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')]", diff --git a/tooling/generate-templates/templates/arm/metric-dynamic.json b/tooling/generate-templates/templates/arm/metric-dynamic.json index 28e1cf149..02239df13 100644 --- a/tooling/generate-templates/templates/arm/metric-dynamic.json +++ b/tooling/generate-templates/templates/arm/metric-dynamic.json @@ -188,9 +188,7 @@ "criterionType": "DynamicThresholdCriterion", "name": "1st criterion", "metricName": "##METRIC_NAME##", - "dimensions": [ - ##DIMENSIONS## - ], + "dimensions": ##DIMENSIONS##, "operator": "[parameters('operator')]", "alertSensitivity": "[parameters('alertSensitivity')]", "failingPeriods": { diff --git a/tooling/generate-templates/templates/arm/metric-static.json b/tooling/generate-templates/templates/arm/metric-static.json index 73a780eb0..3b964b322 100644 --- a/tooling/generate-templates/templates/arm/metric-static.json +++ b/tooling/generate-templates/templates/arm/metric-static.json @@ -171,9 +171,7 @@ { "name": "1st criterion", "metricName": "##METRIC_NAME##", - "dimensions": [ - ##DIMENSIONS## - ], + "dimensions": ##DIMENSIONS##, "operator": "[parameters('operator')]", "threshold": "[parameters('threshold')]", "timeAggregation": "[parameters('timeAggregation')]", diff --git a/tooling/generate-templates/templates/bicep/log.bicep b/tooling/generate-templates/templates/bicep/log.bicep index e154f11bc..3e8a36485 100644 --- a/tooling/generate-templates/templates/bicep/log.bicep +++ b/tooling/generate-templates/templates/bicep/log.bicep @@ -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##' @@ -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' } @@ -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 diff --git a/tooling/generate-templates/templates/bicep/metric-dynamic.bicep b/tooling/generate-templates/templates/bicep/metric-dynamic.bicep index fb68bd096..634eb0fc8 100644 --- a/tooling/generate-templates/templates/bicep/metric-dynamic.bicep +++ b/tooling/generate-templates/templates/bicep/metric-dynamic.bicep @@ -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: { diff --git a/tooling/generate-templates/templates/bicep/metric-static.bicep b/tooling/generate-templates/templates/bicep/metric-static.bicep index 1258b56af..3a097271f 100644 --- a/tooling/generate-templates/templates/bicep/metric-static.bicep +++ b/tooling/generate-templates/templates/bicep/metric-static.bicep @@ -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