Skip to content

Commit

Permalink
Add cluster scope to alert rule groups for linking them with UX (#600)
Browse files Browse the repository at this point in the history
* Removing duplicate alerts from ci recommended alerts

* Remove test branch

* Remove preview keyword from policy readme

* Add cluster id scope to rule groups for alerts to be linked to UX

* adding terraform update
  • Loading branch information
Sohamdg081992 authored Sep 27, 2023
1 parent 1641939 commit be7398b
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 36 deletions.
12 changes: 8 additions & 4 deletions AddonArmTemplate/FullAzureMonitorMetricsProfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@
"properties": {
"description": "[concat(variables('nodeRecordingRuleGroupDescription'), variables('version'))]",
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]"
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"clusterName": "[variables('clusterName')]",
"interval": "PT1M",
Expand Down Expand Up @@ -281,7 +282,8 @@
"properties": {
"description": "[concat(variables('kubernetesRecordingRuleGroupDescription'), variables('version'))]",
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]"
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"clusterName": "[variables('clusterName')]",
"interval": "PT1M",
Expand Down Expand Up @@ -385,7 +387,8 @@
"properties": {
"description": "[concat(variables('RecordingRuleGroupDescriptionWin'), variables('version'))]",
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]"
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"enabled": "[parameters('enableWindowsRecordingRules')]",
"clusterName": "[variables('clusterName')]",
Expand Down Expand Up @@ -462,7 +465,8 @@
"properties": {
"description": "[concat(variables('RecordingRuleGroupDescriptionWin'), variables('version'))]",
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]"
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"enabled": "[parameters('enableWindowsRecordingRules')]",
"clusterName": "[variables('clusterName')]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"properties": {
"description": "[concat(variables('RecordingRuleGroupDescriptionWin'), variables('version'))]",
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]"
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"enabled": true,
"clusterName": "[variables('clusterName')]",
Expand Down Expand Up @@ -133,7 +134,8 @@
"properties": {
"description": "[concat(variables('RecordingRuleGroupDescriptionWin'), variables('version'))]",
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]"
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"enabled": true,
"clusterName": "[variables('clusterName')]",
Expand Down Expand Up @@ -211,4 +213,4 @@
}
}
]
}
}
8 changes: 2 additions & 6 deletions AddonBicepTemplate/AzureMonitorAlertsProfile.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ resource recommendedAlerts 'Microsoft.AlertsManagement/prometheusRuleGroups@2023
location: location
properties: {
description: 'Kubernetes Alert RuleGroup-RecommendedCIAlerts - 0.1'
scopes: [
monitorWorkspace.id
]
scopes: [monitorWorkspace.id,aksResourceId]
clusterName: split(aksResourceId, '/')[8]
enabled: true
interval: 'PT5M'
Expand Down Expand Up @@ -241,9 +239,7 @@ resource communityALerts 'Microsoft.AlertsManagement/prometheusRuleGroups@2023-0
location: location
properties: {
description: 'Kubernetes Alert RuleGroup-communityCIAlerts - 0.1'
scopes: [
monitorWorkspace.id
]
scopes: [monitorWorkspace.id,aksResourceId]
clusterName: split(aksResourceId, '/')[8]
enabled: true
interval: 'PT1M'
Expand Down
16 changes: 4 additions & 12 deletions AddonBicepTemplate/FullAzureMonitorMetricsProfile.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ resource nodeRecordingRuleGroup 'Microsoft.AlertsManagement/prometheusRuleGroups
location: azureMonitorWorkspaceLocation
properties: {
description: '${nodeRecordingRuleGroupDescription}${version}'
scopes: [
azureMonitorWorkspaceResourceId
]
scopes: [azureMonitorWorkspaceResourceId,clusterResourceId]
enabled: true
clusterName: clusterName
interval: 'PT1M'
Expand Down Expand Up @@ -201,9 +199,7 @@ resource kubernetesRecordingRuleGroup 'Microsoft.AlertsManagement/prometheusRule
location: azureMonitorWorkspaceLocation
properties: {
description: '${kubernetesRecordingRuleGroupDescription}${version}'
scopes: [
azureMonitorWorkspaceResourceId
]
scopes: [azureMonitorWorkspaceResourceId,clusterResourceId]
enabled: true
clusterName: clusterName
interval: 'PT1M'
Expand Down Expand Up @@ -305,9 +301,7 @@ resource nodeRecordingRuleGroupNameWin 'Microsoft.AlertsManagement/prometheusRul
location: azureMonitorWorkspaceLocation
properties: {
description: '${RecordingRuleGroupDescriptionWin}${version}'
scopes: [
azureMonitorWorkspaceResourceId
]
scopes: [azureMonitorWorkspaceResourceId,clusterResourceId]
enabled: enableWindowsRecordingRules
clusterName: clusterName
interval: 'PT1M'
Expand Down Expand Up @@ -381,9 +375,7 @@ resource nodeAndKubernetesRecordingRuleGroupNameWin 'Microsoft.AlertsManagement/
location: azureMonitorWorkspaceLocation
properties: {
description: '${RecordingRuleGroupDescriptionWin}${version}'
scopes: [
azureMonitorWorkspaceResourceId
]
scopes: [azureMonitorWorkspaceResourceId,clusterResourceId]
enabled: enableWindowsRecordingRules
clusterName: clusterName
interval: 'PT1M'
Expand Down
16 changes: 12 additions & 4 deletions AddonPolicyTemplate/AddonPolicyMetricsProfile.rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@
"location": "[parameters('azureMonitorWorkspaceLocation')]",
"properties": {
"description": "[concat(variables('nodeRecordingRuleGroupDescription'), variables('version'))]",
"scopes": ["[parameters('azureMonitorWorkspaceResourceId')]"],
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"clusterName": "[variables('clusterName')]",
"interval": "PT1M",
"rules": [
Expand Down Expand Up @@ -283,7 +286,10 @@
"location": "[parameters('azureMonitorWorkspaceLocation')]",
"properties": {
"description": "[concat(variables('kubernetesRecordingRuleGroupDescription'), variables('version'))]",
"scopes": ["[parameters('azureMonitorWorkspaceResourceId')]"],
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"clusterName": "[variables('clusterName')]",
"interval": "PT1M",
"rules": [
Expand Down Expand Up @@ -386,7 +392,8 @@
"properties": {
"description": "[concat(variables('RecordingRuleGroupDescriptionWin'), variables('version'))]",
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]"
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"enabled": "[parameters('enableWindowsRecordingRules')]",
"clusterName": "[variables('clusterName')]",
Expand Down Expand Up @@ -463,7 +470,8 @@
"properties": {
"description": "[concat(variables('RecordingRuleGroupDescriptionWin'), variables('version'))]",
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]"
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"enabled": "[parameters('enableWindowsRecordingRules')]",
"clusterName": "[variables('clusterName')]",
Expand Down
8 changes: 4 additions & 4 deletions AddonTerraformTemplate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ resource "azurerm_monitor_alert_prometheus_rule_group" "node_recording_rules_rul
description = "Node Recording Rules Rule Group"
rule_group_enabled = true
interval = "PT1M"
scopes = [azurerm_monitor_workspace.amw.id]
scopes = [azurerm_monitor_workspace.amw.id,azurerm_kubernetes_cluster.k8s.id]

rule {
enabled = true
Expand Down Expand Up @@ -209,7 +209,7 @@ resource "azurerm_monitor_alert_prometheus_rule_group" "kubernetes_recording_rul
description = "Kubernetes Recording Rules Rule Group"
rule_group_enabled = true
interval = "PT1M"
scopes = [azurerm_monitor_workspace.amw.id]
scopes = [azurerm_monitor_workspace.amw.id,azurerm_kubernetes_cluster.k8s.id]

rule {
enabled = true
Expand Down Expand Up @@ -366,7 +366,7 @@ resource "azurerm_monitor_alert_prometheus_rule_group" "node_and_kubernetes_reco
description = "Node and Kubernetes Recording Rules Rule Group for Windows Nodes"
rule_group_enabled = true
interval = "PT1M"
scopes = [azurerm_monitor_workspace.amw.id]
scopes = [azurerm_monitor_workspace.amw.id,azurerm_kubernetes_cluster.k8s.id]

rule {
enabled = true
Expand Down Expand Up @@ -497,7 +497,7 @@ resource "azurerm_monitor_alert_prometheus_rule_group" "node_recording_rules_rul
description = "Node and Kubernetes Recording Rules Rule Group for Windows Nodes"
rule_group_enabled = true
interval = "PT1M"
scopes = [azurerm_monitor_workspace.amw.id]
scopes = [azurerm_monitor_workspace.amw.id,azurerm_kubernetes_cluster.k8s.id]

rule {
enabled = true
Expand Down
9 changes: 8 additions & 1 deletion GeneratedMonitoringArtifacts/Default/DefaultAlerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"description": "Cluster name"
}
},
"clusterResourceId": {
"type": "string",
"metadata": {
"description": "Cluster Resource Id"
}
},
"actionGroupResourceId": {
"type": "string",
"metadata": {
Expand Down Expand Up @@ -40,7 +46,8 @@
"properties": {
"description": "[concat(variables('kubernetesAlertRuleGroupDescription'), variables('version'))]",
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]"
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"clusterName": "[parameters('clusterName')]",
"interval": "PT1M",
Expand Down
11 changes: 10 additions & 1 deletion GeneratedMonitoringArtifacts/Default/DefaultRecordingRules.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"description": "Cluster name"
}
},
"clusterResourceId": {
"type": "string",
"metadata": {
"description": "Cluster Resource Id"
}
},
"azureMonitorWorkspaceResourceId": {
"type": "string",
"metadata": {
Expand Down Expand Up @@ -41,7 +47,10 @@
"location": "[parameters('location')]",
"properties": {
"description": "[concat(variables('nodeRecordingRuleGroupDescription'), variables('version'))]",
"scopes": [ "[parameters('azureMonitorWorkspaceResourceId')]" ],
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"enabled": true,
"clusterName": "[parameters('clusterName')]",
"interval": "PT1M",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"description": "Cluster name"
}
},
"clusterResourceId": {
"type": "string",
"metadata": {
"description": "Cluster Resource Id"
}
},
"actionGroupResourceId": {
"type": "string",
"metadata": {
Expand Down Expand Up @@ -40,7 +46,8 @@
"properties": {
"description": "[concat(variables('kubernetesAlertRuleGroupDescription'), variables('version'))]",
"scopes": [
"[parameters('azureMonitorWorkspaceResourceId')]"
"[parameters('azureMonitorWorkspaceResourceId')]",
"[parameters('clusterResourceId')]"
],
"clusterName": "[parameters('clusterName')]",
"enabled": true,
Expand Down

0 comments on commit be7398b

Please sign in to comment.