From 268dd34c0100757acfd304b14ed42bed4cd8cf80 Mon Sep 17 00:00:00 2001 From: Duncan Watson Date: Thu, 12 Dec 2024 16:29:40 +0000 Subject: [PATCH] EES-5687 - reduced various common alert types to a set of "base" alert configuration inherited by different resource-specific alerts --- .../appGateways/responseTimeAlert.bicep | 23 +++-------- .../appServicePlans/cpuPercentageAlert.bicep | 23 +++-------- .../memoryPercentageAlert.bicep | 23 +++-------- .../alerts/baseCpuPercentageAlert.bicep | 38 +++++++++++++++++++ .../alerts/baseMemoryPercentageAlert.bicep | 38 +++++++++++++++++++ .../alerts/baseResponseTimeAlert.bicep | 38 +++++++++++++++++++ .../containerApps/cpuPercentageAlert.bicep | 23 +++-------- .../containerApps/memoryPercentageAlert.bicep | 23 +++-------- .../containerApps/responseTimeAlert.bicep | 23 +++-------- .../clientConnectionsWaitingAlert.bicep | 2 +- .../flexibleServers/cpuPercentageAlert.bicep | 23 +++-------- .../flexibleServers/diskBandwidthAlert.bicep | 2 +- .../flexibleServers/diskIopsAlert.bicep | 2 +- .../memoryPercentageAlert.bicep | 23 +++-------- .../alerts/storageAccounts/latencyAlert.bicep | 23 +++-------- 15 files changed, 162 insertions(+), 165 deletions(-) create mode 100644 infrastructure/templates/public-api/components/alerts/baseCpuPercentageAlert.bicep create mode 100644 infrastructure/templates/public-api/components/alerts/baseMemoryPercentageAlert.bicep create mode 100644 infrastructure/templates/public-api/components/alerts/baseResponseTimeAlert.bicep diff --git a/infrastructure/templates/public-api/components/alerts/appGateways/responseTimeAlert.bicep b/infrastructure/templates/public-api/components/alerts/appGateways/responseTimeAlert.bicep index fa5fc24c9f..bb26e9c29b 100644 --- a/infrastructure/templates/public-api/components/alerts/appGateways/responseTimeAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/appGateways/responseTimeAlert.bicep @@ -1,32 +1,19 @@ -import { Severity } from '../types.bicep' - @description('Names of the resources that these alerts are being applied to.') param resourceNames string[] -@description('The alert severity.') -param severity Severity = 'Warning' - @description('Name of the Alerts Group used to send alert messages.') param alertsGroupName string @description('Tags with which to tag the resource in Azure.') param tagValues object -module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { - name: '${name}ResponseTimeAlertModule' +module alerts '../baseResponseTimeAlert.bicep' = { + name: '${resourceNames[0]}ResponseTimeAlertModule' params: { - alertName: '${name}-response-time' - resourceIds: [resourceId('Microsoft.Network/applicationGateways', name)] + resourceNames: resourceNames resourceType: 'Microsoft.Network/applicationGateways' - query: { - metric: 'ApplicationGatewayTotalTime' - aggregation: 'Average' - operator: 'GreaterThan' - } - evaluationFrequency: 'PT1M' - windowSize: 'PT5M' - severity: severity + metricName: 'ApplicationGatewayTotalTime' alertsGroupName: alertsGroupName tagValues: tagValues } -}] +} diff --git a/infrastructure/templates/public-api/components/alerts/appServicePlans/cpuPercentageAlert.bicep b/infrastructure/templates/public-api/components/alerts/appServicePlans/cpuPercentageAlert.bicep index bd82117b96..726090757e 100644 --- a/infrastructure/templates/public-api/components/alerts/appServicePlans/cpuPercentageAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/appServicePlans/cpuPercentageAlert.bicep @@ -1,32 +1,19 @@ -import { Severity } from '../types.bicep' - @description('Names of the resources that these alerts are being applied to.') param resourceNames string[] -@description('The alert severity.') -param severity Severity = 'Warning' - @description('Name of the Alerts Group used to send alert messages.') param alertsGroupName string @description('Tags with which to tag the resource in Azure.') param tagValues object -module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { - name: '${name}CpuPercentageAlertModule' +module alerts '../baseCpuPercentageAlert.bicep' = { + name: '${resourceNames[0]}CpuPercentageAlertModule' params: { - alertName: '${name}-cpu-percentage' - resourceIds: [resourceId('Microsoft.Web/serverfarms', name)] + resourceNames: resourceNames resourceType: 'Microsoft.Web/serverfarms' - query: { - metric: 'CpuPercentage' - aggregation: 'Average' - operator: 'GreaterThan' - } - evaluationFrequency: 'PT5M' - windowSize: 'PT15M' - severity: severity + metricName: 'CpuPercentage' alertsGroupName: alertsGroupName tagValues: tagValues } -}] +} diff --git a/infrastructure/templates/public-api/components/alerts/appServicePlans/memoryPercentageAlert.bicep b/infrastructure/templates/public-api/components/alerts/appServicePlans/memoryPercentageAlert.bicep index 23c67d940e..7086ed2974 100644 --- a/infrastructure/templates/public-api/components/alerts/appServicePlans/memoryPercentageAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/appServicePlans/memoryPercentageAlert.bicep @@ -1,32 +1,19 @@ -import { Severity } from '../types.bicep' - @description('Names of the resources that these alerts are being applied to.') param resourceNames string[] -@description('The alert severity.') -param severity Severity = 'Warning' - @description('Name of the Alerts Group used to send alert messages.') param alertsGroupName string @description('Tags with which to tag the resource in Azure.') param tagValues object -module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { - name: '${name}MemoryPercentageAlertModule' +module alerts '../baseMemoryPercentageAlert.bicep' = { + name: '${resourceNames[0]}MemoryPercentageAlertModule' params: { - alertName: '${name}-memory-percentage' - resourceIds: [resourceId('Microsoft.Web/serverfarms', name)] + resourceNames: resourceNames resourceType: 'Microsoft.Web/serverfarms' - query: { - metric: 'MemoryPercentage' - aggregation: 'Average' - operator: 'GreaterThan' - } - evaluationFrequency: 'PT5M' - windowSize: 'PT15M' - severity: severity + metricName: 'MemoryPercentage' alertsGroupName: alertsGroupName tagValues: tagValues } -}] +} diff --git a/infrastructure/templates/public-api/components/alerts/baseCpuPercentageAlert.bicep b/infrastructure/templates/public-api/components/alerts/baseCpuPercentageAlert.bicep new file mode 100644 index 0000000000..476492206c --- /dev/null +++ b/infrastructure/templates/public-api/components/alerts/baseCpuPercentageAlert.bicep @@ -0,0 +1,38 @@ +import { Severity } from 'types.bicep' + +@description('Names of the resources that these alerts are being applied to.') +param resourceNames string[] + +@description('Names of the resources that these alerts are being applied to.') +param resourceType string + +@description('Names of the resources that these alerts are being applied to.') +param metricName string + +@description('The alert severity.') +param severity Severity = 'Warning' + +@description('Name of the Alerts Group used to send alert messages.') +param alertsGroupName string + +@description('Tags with which to tag the resource in Azure.') +param tagValues object + +module alerts 'dynamicMetricAlert.bicep' = [for name in resourceNames: { + name: '${name}CpuPercentBaseAlertModule' + params: { + alertName: '${name}-cpu-percentage' + resourceIds: [resourceId(resourceType, name)] + resourceType: resourceType + query: { + metric: metricName + aggregation: 'Average' + operator: 'GreaterThan' + } + evaluationFrequency: 'PT5M' + windowSize: 'PT15M' + severity: severity + alertsGroupName: alertsGroupName + tagValues: tagValues + } +}] diff --git a/infrastructure/templates/public-api/components/alerts/baseMemoryPercentageAlert.bicep b/infrastructure/templates/public-api/components/alerts/baseMemoryPercentageAlert.bicep new file mode 100644 index 0000000000..a379a8a964 --- /dev/null +++ b/infrastructure/templates/public-api/components/alerts/baseMemoryPercentageAlert.bicep @@ -0,0 +1,38 @@ +import { Severity } from 'types.bicep' + +@description('Names of the resources that these alerts are being applied to.') +param resourceNames string[] + +@description('Names of the resources that these alerts are being applied to.') +param resourceType string + +@description('Names of the resources that these alerts are being applied to.') +param metricName string + +@description('The alert severity.') +param severity Severity = 'Warning' + +@description('Name of the Alerts Group used to send alert messages.') +param alertsGroupName string + +@description('Tags with which to tag the resource in Azure.') +param tagValues object + +module alerts 'dynamicMetricAlert.bicep' = [for name in resourceNames: { + name: '${name}MemoryPercentBaseAlertModule' + params: { + alertName: '${name}-memory-percentage' + resourceIds: [resourceId(resourceType, name)] + resourceType: resourceType + query: { + metric: metricName + aggregation: 'Average' + operator: 'GreaterThan' + } + evaluationFrequency: 'PT5M' + windowSize: 'PT15M' + severity: severity + alertsGroupName: alertsGroupName + tagValues: tagValues + } +}] diff --git a/infrastructure/templates/public-api/components/alerts/baseResponseTimeAlert.bicep b/infrastructure/templates/public-api/components/alerts/baseResponseTimeAlert.bicep new file mode 100644 index 0000000000..f4b07bc892 --- /dev/null +++ b/infrastructure/templates/public-api/components/alerts/baseResponseTimeAlert.bicep @@ -0,0 +1,38 @@ +import { Severity } from 'types.bicep' + +@description('Names of the resources that these alerts are being applied to.') +param resourceNames string[] + +@description('Names of the resources that these alerts are being applied to.') +param resourceType string + +@description('Names of the resources that these alerts are being applied to.') +param metricName string + +@description('The alert severity.') +param severity Severity = 'Warning' + +@description('Name of the Alerts Group used to send alert messages.') +param alertsGroupName string + +@description('Tags with which to tag the resource in Azure.') +param tagValues object + +module alerts 'dynamicMetricAlert.bicep' = [for name in resourceNames: { + name: '${name}ResponseTimeBaseAlertModule' + params: { + alertName: '${name}-response-time' + resourceIds: [resourceId(resourceType, name)] + resourceType: resourceType + query: { + metric: metricName + aggregation: 'Average' + operator: 'GreaterThan' + } + evaluationFrequency: 'PT5M' + windowSize: 'PT15M' + severity: severity + alertsGroupName: alertsGroupName + tagValues: tagValues + } +}] diff --git a/infrastructure/templates/public-api/components/alerts/containerApps/cpuPercentageAlert.bicep b/infrastructure/templates/public-api/components/alerts/containerApps/cpuPercentageAlert.bicep index 8f2645ef80..7e02a004de 100644 --- a/infrastructure/templates/public-api/components/alerts/containerApps/cpuPercentageAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/containerApps/cpuPercentageAlert.bicep @@ -1,32 +1,19 @@ -import { Severity } from '../types.bicep' - @description('Names of the resources that these alerts are being applied to.') param resourceNames string[] -@description('The alert severity.') -param severity Severity = 'Warning' - @description('Name of the Alerts Group used to send alert messages.') param alertsGroupName string @description('Tags with which to tag the resource in Azure.') param tagValues object -module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { - name: '${name}CpuPercentageAlertModule' +module alerts '../baseCpuPercentageAlert.bicep' = { + name: '${resourceNames[0]}CpuPercentageAlertModule' params: { - alertName: '${name}-cpu-percentage' - resourceIds: [resourceId('Microsoft.App/containerApps', name)] + resourceNames: resourceNames resourceType: 'Microsoft.App/containerApps' - query: { - metric: 'CpuPercentage' - aggregation: 'Average' - operator: 'GreaterThan' - } - evaluationFrequency: 'PT5M' - windowSize: 'PT15M' - severity: severity + metricName: 'CpuPercentage' alertsGroupName: alertsGroupName tagValues: tagValues } -}] +} diff --git a/infrastructure/templates/public-api/components/alerts/containerApps/memoryPercentageAlert.bicep b/infrastructure/templates/public-api/components/alerts/containerApps/memoryPercentageAlert.bicep index 1b477eec6a..70f45e094f 100644 --- a/infrastructure/templates/public-api/components/alerts/containerApps/memoryPercentageAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/containerApps/memoryPercentageAlert.bicep @@ -1,32 +1,19 @@ -import { Severity } from '../types.bicep' - @description('Names of the resources that these alerts are being applied to.') param resourceNames string[] -@description('The alert severity.') -param severity Severity = 'Warning' - @description('Name of the Alerts Group used to send alert messages.') param alertsGroupName string @description('Tags with which to tag the resource in Azure.') param tagValues object -module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { - name: '${name}MemoryPercentageAlertModule' +module alerts '../baseMemoryPercentageAlert.bicep' = { + name: '${resourceNames[0]}MemoryPercentageAlertModule' params: { - alertName: '${name}-memory-percentage' - resourceIds: [resourceId('Microsoft.App/containerApps', name)] + resourceNames: resourceNames resourceType: 'Microsoft.App/containerApps' - query: { - metric: 'MemoryPercentage' - aggregation: 'Average' - operator: 'GreaterThan' - } - evaluationFrequency: 'PT5M' - windowSize: 'PT15M' - severity: severity + metricName: 'MemoryPercentage' alertsGroupName: alertsGroupName tagValues: tagValues } -}] +} diff --git a/infrastructure/templates/public-api/components/alerts/containerApps/responseTimeAlert.bicep b/infrastructure/templates/public-api/components/alerts/containerApps/responseTimeAlert.bicep index 7957c351fd..dba89410fd 100644 --- a/infrastructure/templates/public-api/components/alerts/containerApps/responseTimeAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/containerApps/responseTimeAlert.bicep @@ -1,32 +1,19 @@ -import { Severity } from '../types.bicep' - @description('Names of the resources that these alerts are being applied to.') param resourceNames string[] -@description('The alert severity.') -param severity Severity = 'Warning' - @description('Name of the Alerts Group used to send alert messages.') param alertsGroupName string @description('Tags with which to tag the resource in Azure.') param tagValues object -module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { - name: '${name}LatencyAlertModule' +module alerts '../baseResponseTimeAlert.bicep' = { + name: '${resourceNames[0]}ResponseTimeAlertModule' params: { - alertName: '${name}-latency' - resourceIds: [resourceId('Microsoft.App/containerApps', name)] + resourceNames: resourceNames resourceType: 'Microsoft.App/containerApps' - query: { - metric: 'ResponseTime' - aggregation: 'Average' - operator: 'GreaterThan' - } - evaluationFrequency: 'PT1M' - windowSize: 'PT5M' - severity: severity + metricName: 'ResponseTime' alertsGroupName: alertsGroupName tagValues: tagValues } -}] +} diff --git a/infrastructure/templates/public-api/components/alerts/flexibleServers/clientConnectionsWaitingAlert.bicep b/infrastructure/templates/public-api/components/alerts/flexibleServers/clientConnectionsWaitingAlert.bicep index 70a626caaf..ea54d5e517 100644 --- a/infrastructure/templates/public-api/components/alerts/flexibleServers/clientConnectionsWaitingAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/flexibleServers/clientConnectionsWaitingAlert.bicep @@ -13,7 +13,7 @@ param alertsGroupName string param tagValues object module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { - name: '${name}ClientConnectionsAlertModule' + name: '${name}ClientConnectionsWaitingAlertModule' params: { alertName: '${name}-query-time' resourceIds: [resourceId('Microsoft.DBforPostgreSQL/flexibleServers', name)] diff --git a/infrastructure/templates/public-api/components/alerts/flexibleServers/cpuPercentageAlert.bicep b/infrastructure/templates/public-api/components/alerts/flexibleServers/cpuPercentageAlert.bicep index 88c28087be..e77881c069 100644 --- a/infrastructure/templates/public-api/components/alerts/flexibleServers/cpuPercentageAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/flexibleServers/cpuPercentageAlert.bicep @@ -1,32 +1,19 @@ -import { Severity } from '../types.bicep' - @description('Names of the resources that these alerts are being applied to.') param resourceNames string[] -@description('The alert severity.') -param severity Severity = 'Warning' - @description('Name of the Alerts Group used to send alert messages.') param alertsGroupName string @description('Tags with which to tag the resource in Azure.') param tagValues object -module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { - name: '${name}CpuPercentageAlertModule' +module alerts '../baseCpuPercentageAlert.bicep' = { + name: '${resourceNames[0]}CpuPercentageAlertModule' params: { - alertName: '${name}-cpu-percentage' - resourceIds: [resourceId('Microsoft.DBforPostgreSQL/flexibleServers', name)] + resourceNames: resourceNames resourceType: 'Microsoft.DBforPostgreSQL/flexibleServers' - query: { - metric: 'cpu_percent' - aggregation: 'Maximum' - operator: 'GreaterThan' - } - evaluationFrequency: 'PT5M' - windowSize: 'PT15M' - severity: severity + metricName: 'cpu_percent' alertsGroupName: alertsGroupName tagValues: tagValues } -}] +} diff --git a/infrastructure/templates/public-api/components/alerts/flexibleServers/diskBandwidthAlert.bicep b/infrastructure/templates/public-api/components/alerts/flexibleServers/diskBandwidthAlert.bicep index 001d3f4c3a..5eaf2d2727 100644 --- a/infrastructure/templates/public-api/components/alerts/flexibleServers/diskBandwidthAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/flexibleServers/diskBandwidthAlert.bicep @@ -20,7 +20,7 @@ module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { resourceType: 'Microsoft.DBforPostgreSQL/flexibleServers' query: { metric: 'disk_bandwidth_consumed_percentage' - aggregation: 'Maximum' + aggregation: 'Average' operator: 'GreaterThan' } evaluationFrequency: 'PT5M' diff --git a/infrastructure/templates/public-api/components/alerts/flexibleServers/diskIopsAlert.bicep b/infrastructure/templates/public-api/components/alerts/flexibleServers/diskIopsAlert.bicep index 73ab8e9439..63016e4514 100644 --- a/infrastructure/templates/public-api/components/alerts/flexibleServers/diskIopsAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/flexibleServers/diskIopsAlert.bicep @@ -20,7 +20,7 @@ module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { resourceType: 'Microsoft.DBforPostgreSQL/flexibleServers' query: { metric: 'disk_iops_consumed_percentage' - aggregation: 'Maximum' + aggregation: 'Average' operator: 'GreaterThan' } evaluationFrequency: 'PT5M' diff --git a/infrastructure/templates/public-api/components/alerts/flexibleServers/memoryPercentageAlert.bicep b/infrastructure/templates/public-api/components/alerts/flexibleServers/memoryPercentageAlert.bicep index a847d4dcff..419d17a46c 100644 --- a/infrastructure/templates/public-api/components/alerts/flexibleServers/memoryPercentageAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/flexibleServers/memoryPercentageAlert.bicep @@ -1,32 +1,19 @@ -import { Severity } from '../types.bicep' - @description('Names of the resources that these alerts are being applied to.') param resourceNames string[] -@description('The alert severity.') -param severity Severity = 'Warning' - @description('Name of the Alerts Group used to send alert messages.') param alertsGroupName string @description('Tags with which to tag the resource in Azure.') param tagValues object -module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { - name: '${name}MemoryPercentageAlertModule' +module alerts '../baseMemoryPercentageAlert.bicep' = { + name: '${resourceNames[0]}MemoryPercentageAlertModule' params: { - alertName: '${name}-memory-percentage' - resourceIds: [resourceId('Microsoft.DBforPostgreSQL/flexibleServers', name)] + resourceNames: resourceNames resourceType: 'Microsoft.DBforPostgreSQL/flexibleServers' - query: { - metric: 'memory_percent' - aggregation: 'Maximum' - operator: 'GreaterThan' - } - evaluationFrequency: 'PT5M' - windowSize: 'PT15M' - severity: severity + metricName: 'memory_percent' alertsGroupName: alertsGroupName tagValues: tagValues } -}] +} diff --git a/infrastructure/templates/public-api/components/alerts/storageAccounts/latencyAlert.bicep b/infrastructure/templates/public-api/components/alerts/storageAccounts/latencyAlert.bicep index 164c717cff..7acc56ddc6 100644 --- a/infrastructure/templates/public-api/components/alerts/storageAccounts/latencyAlert.bicep +++ b/infrastructure/templates/public-api/components/alerts/storageAccounts/latencyAlert.bicep @@ -1,32 +1,19 @@ -import { Severity } from '../types.bicep' - @description('Names of the resources that these alerts are being applied to.') param resourceNames string[] -@description('The alert severity.') -param severity Severity = 'Warning' - @description('Name of the Alerts Group used to send alert messages.') param alertsGroupName string @description('Tags with which to tag the resource in Azure.') param tagValues object -module alerts '../dynamicMetricAlert.bicep' = [for name in resourceNames: { - name: '${name}LatencyAlertModule' +module alerts '../baseResponseTimeAlert.bicep' = { + name: '${resourceNames[0]}LatencyAlertModule' params: { - alertName: '${name}-latency' - resourceIds: [resourceId('Microsoft.Storage/storageAccounts', name)] + resourceNames: resourceNames resourceType: 'Microsoft.Storage/storageAccounts' - query: { - metric: 'SuccessE2ELatency' - aggregation: 'Average' - operator: 'GreaterThan' - } - evaluationFrequency: 'PT1M' - windowSize: 'PT5M' - severity: severity + metricName: 'SuccessE2ELatency' alertsGroupName: alertsGroupName tagValues: tagValues } -}] +}