Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…e-alerts into computerstoinclude_remove
  • Loading branch information
tgolovina committed Feb 21, 2025
2 parents 172c9b9 + acf2015 commit db1ff22
Show file tree
Hide file tree
Showing 1,261 changed files with 2,817 additions and 50 deletions.
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Replace this with a brief description of what this Pull Request fixes, changes,
1. *Replace me*
2. *Replace me*

### Testing evidence

Please provide any testing evidence to show that your Pull Request works/fixes as described and planned (include screenshots, if appropriate).

## As part of this Pull Request I have

- [ ] Read the Contribution Guide and ensured this PR is compliant with the guide
Expand Down
159 changes: 159 additions & 0 deletions .github/actions-pester/Test-ModifiedPolicies.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
Describe 'UnitTest-ModifiedPolicies' {
BeforeAll {
Import-Module -Name $PSScriptRoot\PolicyPesterTestHelper.psm1 -Force -Verbose

$ModifiedFiles = @(Get-PolicyFiles -DiffFilter "M")
if ($ModifiedFiles -ne $null) {
Write-Warning "These are the modified policies:"
$ModifiedFiles | ForEach-Object {
Write-Host "`t$_" -ForegroundColor DarkYellow
}
}
else {
Write-Information "There are no modified policies"
}

$AddedFiles = @(Get-PolicyFiles -DiffFilter "A")
if ($AddedFiles -ne $null) {
Write-Warning "These are the added policies:"
$AddedFiles | ForEach-Object {
Write-Host "`t$_" -ForegroundColor DarkYellow
}
}
else {
Write-Information "There are no added policies"
}

$ModifiedAddedFiles = $ModifiedFiles + $AddedFiles
}

Context "Validate policy metadata" {

It "Check policy metadata version exists" {
$ModifiedAddedFiles | ForEach-Object {
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
$PolicyFile = Split-Path $_ -Leaf
$PolicyMetadataVersion = $PolicyJson.properties.metadata.version
# Write-Warning "$($PolicyFile) - The current metadata version for the policy in the PR branch is : $($PolicyMetadataVersion)"
$PolicyMetadataVersion | Should -Not -BeNullOrEmpty -Because "the [version] attribute does not exist on file [$PolicyFile]."
}
}

It "Check policy metadata version is greater than its previous version" -Skip:($ModifiedFiles -ne $null) {
$ModifiedFiles | ForEach-Object {
$PolicyFile = Split-Path $_ -Leaf
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
$PreviousPolicyDefinitionRawUrl = "https://raw.githubusercontent.com/Azure/azure-monitor-baseline-alerts/main/$_"
$PreviousPolicyDefinitionOutputFile = "./previous-$PolicyFile"
Invoke-WebRequest -Uri $PreviousPolicyDefinitionRawUrl -OutFile $PreviousPolicyDefinitionOutputFile
$PreviousPolicyDefinitionsFile = Get-Content $PreviousPolicyDefinitionOutputFile -Raw | ConvertFrom-Json
$PreviousPolicyDefinitionsFileVersion = $PreviousPolicyDefinitionsFile.properties.metadata.version
# Write-Warning "$($PolicyFile) - The current metadata version for the policy in the main branch is : $($PreviousPolicyDefinitionsFileVersion)"
$PolicyMetadataVersion = $PolicyJson.properties.metadata.version
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
# Write-Warning "$($PolicyFile) - The current metadata version for the policy in the PR branch is : $($PolicyMetadataVersion)"
if (!$PreviousPolicyDefinitionsFileVersion.EndsWith("deprecated")) {
$PolicyMetadataVersion | Should -BeGreaterThan $PreviousPolicyDefinitionsFileVersion -Because "the [version] attribute value of file [$PolicyFile] needs to be incremented when modifying policies."
}
}
}

It "Check deprecated policy contains all required metadata" {
$ModifiedAddedFiles | ForEach-Object {
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
$PolicyFile = Split-Path $_ -Leaf
$PolicyMetadataVersion = $PolicyJson.properties.metadata.version
# Write-Warning "$($PolicyFile) - This is the policy metadata version: $($PolicyMetadataVersion)"
if ($PolicyMetadataVersion.EndsWith("deprecated")) {
# Write-Warning "$($PolicyFile) - Should have the deprecated metadata flag set to true"
$PolicyMetadataDeprecated = $PolicyJson.properties.metadata.deprecated
$PolicyMetadataDeprecated | Should -BeTrue
# Write-Warning "$($PolicyFile) - Should have the supersededBy metadata value set"
$PolicyMetadataSuperseded = $PolicyJson.properties.metadata.supersededBy
$PolicyMetadataSuperseded | Should -Not -BeNullOrEmpty
# Write-Warning "$($PolicyFile) - [Deprecated] should be in the display name"
$PolicyPropertiesDisplayName = $PolicyJson.properties.displayName
$PolicyPropertiesDisplayName | Should -Match "[DEPRECATED]" -Because "the [version] attribute on file [$PolicyFile] needs to end with [DEPRECATED]."
}
}
}

It "Check policy metadata category exists" {
$ModifiedAddedFiles | ForEach-Object {
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
$PolicyFile = Split-Path $_ -Leaf
$PolicyMetadataCategories = $PolicyJson.properties.metadata.category
# Write-Warning "$($PolicyFile) - These are the policy metadata categories: $($PolicyMetadataCategories)"
$PolicyMetadataCategories | Should -Not -BeNullOrEmpty -Because "the [category] attribute on file [$PolicyFile] is empty."
}
}

It "Check policy metadata source is set to azure-monitor-baseline-alerts repo" {
$ModifiedAddedFiles | ForEach-Object {
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
$PolicyFile = Split-Path $_ -Leaf
$PolicyMetadataSource = $PolicyJson.properties.metadata.source
# Write-Warning "$($PolicyFile) - This is the policy source link: $($PolicyMetadataSource)"
$PolicyMetadataSource | Should -Be 'https://github.com/Azure/azure-monitor-baseline-alerts/' -Because "the [source] attribute on file [$PolicyFile] is not set to [https://github.com/Azure/azure-monitor-baseline-alerts/]."
}
}

It "Check policy metadata ALZ Environments are specified for Public, US Gov or China Clouds" {
$ModifiedAddedFiles | ForEach-Object {
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
$PolicyFile = Split-Path $_ -Leaf
$AlzEnvironments = @("AzureCloud", "AzureChinaCloud", "AzureUSGovernment")
$PolicyEnvironments = $PolicyJson.properties.metadata.alzCloudEnvironments
# Write-Warning "$($PolicyFile) - These are the environments: $($PolicyEnvironments)"
$PolicyJson.properties.metadata.alzCloudEnvironments | Should -BeIn $AlzEnvironments -Because "the [alzCloudEnvironments] attribute value does not match [AzureCloud] or [AzureChinaCloud] or [AzureUSGovernment]."
}
}

<# Commenting this block since we use a different name for policy name and file name
It "Check policy metadata name matches policy filename" {
$ModifiedAddedFiles | ForEach-Object {
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
$PolicyFile = Split-Path $_ -Leaf
$PolicyMetadataName = $PolicyJson.name
$PolicyFileNoExt = [System.IO.Path]::GetFileNameWithoutExtension($PolicyFile)
if ($PolicyFileNoExt.Contains("AzureChinaCloud") -or $PolicyFileNoExt.ContEnterpriains("AzureUSGovernment")) {
$PolicyFileNoExt = $PolicyFileNoExt.Substring(0, $PolicyFileNoExt.IndexOf("."))
}
# Write-Warning "$($PolicyFileNoExt) - This is the policy metadata name: $($PolicyMetadataName)"
$PolicyMetadataName | Should -Be $PolicyFileNoExt
}
}#>
}

Context "Validate policy parameters" {
It 'Check for policy parameters have default values' {
$ModifiedAddedFiles | ForEach-Object {
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
$PolicyFile = Split-Path $_ -Leaf
$PolicyMetadataName = $PolicyJson.name
$ExcludePolicy = @()
$ExcludeParams = @("ALZManagementSubscriptionId", "BYOUserAssignedManagedIdentityResourceId")
if ($PolicyMetadataName -notin $ExcludePolicy) {
$PolicyParameters = $PolicyJson.properties.parameters
if ($PolicyParameters | Get-Member -MemberType NoteProperty) {
$Parameters = $PolicyParameters | Get-Member -MemberType NoteProperty | Select-Object -Expand Name
# Write-Warning "$($PolicyFile) - These are the params: $($Parameters)"
$Parameters = $PolicyParameters | Get-Member -MemberType NoteProperty
$Parameters | ForEach-Object {
$key = $_.name
if ($key -notin $ExcludeParams) {
$defaultValue = $PolicyParameters.$key | Get-Member -MemberType NoteProperty | Where-Object Name -EQ "defaultValue"
# Write-Warning "$($PolicyFile) - Parameter: $($key) - Default Value: $($defaultValue)"
$PolicyParameters.$key.defaultValue | Should -Not -Because "the [defaultValue] for parameter [$key] is empty."
}
}
}
}
}
}
}

AfterAll {
# These are not the droids you are looking for...
}
}
2 changes: 1 addition & 1 deletion .github/workflows/check-policy-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
jobs:
check-policy:
name: Check Policy Build
runs-on: windows-latest
runs-on: ubuntu-latest

steps:
- name: Check out repository
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/check-policy-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Check Policy Version

##########################################
# Start the job on PR for all branches #
##########################################

# yamllint disable-line rule:truthy
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
paths:
- "services/**.json"
- "patterns/alz/policySetDefinitions/**.json"
workflow_dispatch: {}

env:
POLICY_DIR: "services"
POLICYSET_DIR: "patterns/alz/policySetDefinitions"

jobs:
validate-policy-files:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Pester Test for Modified Policies
shell: pwsh
run: |
Import-Module Pester -Force
$pesterConfiguration = @{
Run = @{
Container = New-PesterContainer -Path "./.github/actions-pester/Test-ModifiedPolicies.Tests.ps1"
PassThru = $true
}
Output = @{
Verbosity = 'Detailed'
}
}
$result = Invoke-Pester -Configuration $pesterConfiguration
exit $result.FailedCount
11 changes: 8 additions & 3 deletions docs/content/faq/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@ title: Frequently Asked Questions (FAQs)
weight: 20
---

This FAQ page provides answers to common questions about Azure Monitor Baseline Alerts (AMBA). It covers a variety of topics, including the types of alerts that can be monitored, how to deploy AMBA, best practices, and where to find additional learning resources. Whether you're just getting started with AMBA or looking to deepen your understanding, this FAQ page has you covered!
This FAQ page provides answers to common questions about Azure Monitor Baseline Alerts (AMBA). It covers a variety of topics, including the types of alerts that can be monitored, how to deploy AMBA, best practices, and where to find additional learning resources. Links to FAQ pages of specific patterns and scenarios such as ALZ, AVD, and AVS are also included. Whether you're just getting started with AMBA or looking to deepen your understanding, we have you covered!

{{< hint type=tip >}}

Got an unanswered question? Create a [GitHub Issue](https://github.com/Azure/azure-monitor-baseline-alerts/issues) so we can get it answered and added here for everyone's benefit 👍

{{< /hint >}}

{{< toc >}}
## Patterns and Specialized FAQ's

## General Questions
- **[Azure Landing Zones](https://azure.github.io/azure-monitor-baseline-alerts/patterns/alz/Resources/FAQ/)**
- **[Azure Virtual Desktop](https://azure.github.io/azure-monitor-baseline-alerts/patterns/specialized/avd/FAQ/)**
- **[Azure VMware Solution](https://azure.github.io/azure-monitor-baseline-alerts/patterns/specialized/avs/FAQ/)**
- **[SAP on Azure](https://azure.github.io/azure-monitor-baseline-alerts/patterns/specialized/sap/FAQ/)**

## General AMBA FAQ's

1. **What type of alerts can AMBA monitor?**
AMBA supports a wide range of alert metrics that can be monitored. This includes CPU Utilization, Memory Usage, Networking Traffic, Application Response Times, Quota Utilization, Storage Usage, and many more.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This initiative is intended for relevant policy assignment to networking compone
| Deploy VNetG Tunnel Bandwidth Alert | ALZ_VnetGwTunnelBW | [deploy-vnetg_bandwidthutilization_alert.json](../../../../services/Network/virtualNetworkGateways/Deploy-VNETG-BandwidthUtilization-Alert.json) | deployIfNotExists |
| Deploy VNetG Tunnel Egress Alert | ALZ_VnetGwTunnelEgress | [deploy-vnetg_egress_alert.json](../../../../services/Network/virtualNetworkGateways/Deploy-VNETG-Egress-Alert.json) | disabled |
| Deploy VNetG Tunnel Ingress Alert | ALZ_VnetGwTunnelIngress | [deploy-vnetg_ingress_alert.json](../../../../services/Network/virtualNetworkGateways/Deploy-VNETG-Ingress-Alert.json) | disabled |
| Deploy_VPNGw_BandwidthUtil_Alert | ALZ_VPNGWBandWidthUtil | [deploy-vpng_bandwidthutilization_alert.json](../../../../services/Network/vpnGateways/Deploy-VPNG-BandwidthUtilization-Alert.json) | deployIfNotExists |
| Deploy VPNGw BandwidthUtil Alert | ALZ_VPNGWBandWidthUtil | [deploy-vpng_bandwidthutilization_alert.json](../../../../services/Network/vpnGateways/Deploy-VPNG-BandwidthUtilization-Alert.json) | deployIfNotExists |
| Deploy VPNG Egress Alert | ALZ_VPNGWEgress | [deploy-vpng_egress_alert.json](../../../../services/Network/vpnGateways/Deploy-VPNG-Egress-Alert.json) | disabled |
| Deploy VPNG Egress Packet Drop Count Alert | ALZ_VPNGWTunnelEgressPacketDropCount | [deploy-vpng_egresspacketdropcount_alert.json](../../../../services/Network/vpnGateways/Deploy-VPNG-EgressPacketDropCount-Alert.json) | deployIfNotExists |
| Deploy VPNG Egress Packet Drop Mismatch Alert | ALZ_VPNGWTunnelEgressPacketDropMismatch | [deploy-vpng_egresspacketdropmismatch_alert.json](../../../../services/Network/vpnGateways/Deploy-VPNG-EgressPacketDropMismatch-Alert.json) | deployIfNotExists |
Expand Down Expand Up @@ -93,8 +93,10 @@ This initiative is intended for relevant policy assignment to management compone
| ----------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------- |
| Deploy Automation Account TotalJob Alert | ALZ_AATotalJob | [deploy-aa_totaljob_alert.json](../../../../services/Automation/automationAccounts/Deploy-AA-TotalJob-Alert.json) | deployIfNotExists |
| Deploy RV Backup Health Monitoring Alerts | ALZ_RVBackupHealth | [deploy-rv_backuphealth_alert.json](../../../../services/RecoveryServices/vaults/Modify-RSV-BackupHealth-Alert.json) | modify |
| Deploy RV ASR Health Monitoring Alerts | ALZ_RVASRHealth | [deploy-rv_rsvhealth_alert.json](../../../../services/RecoveryServices/vaults/Modify-RSV-ASRHealth-Alert.json) | modify |
| Deploy SA Availability Alert | ALZ_StorageAccountAvailability | [deploy-sa_availability_alert.json](../../../../services/Storage/storageAccounts/Deploy-SA-Availability-Alert.json) | deployIfNotExists |
| Deploy Activity Log Storage Account Delete Alert | ALZ_activitySADelete | [Deploy_activitylog_StorageAccount_Delete.json](../../../../services/Storage/storageAccounts/Deploy_activitylog_StorageAccount_Delete.json) | deployIfNotExists |
| Deploy LA Workspace Daily Cap Limit Reached Alert | ALZ_LAWorkspaceDailyCapLimitReached | [Deploy_LAWorkspace_DailyCapLimitReached_Alert.json](../../../../services/OperationalInsights/workspaces/Deploy-ActivityLog-LAWorkspace-DailyCapLimitReached-Alert.json) | deployIfNotExists |
| Deploy Activity Log LA Workspace Delete Alert | ALZ_activityLAWDelete | [deploy-activitylog-LAWorkspace-Del.json](../../../../services/OperationalInsights/workspaces/Deploy-ActivityLog-LAWorkspace-Del.json) | deployIfNotExists |
| Deploy Activity Log LA Workspace Regenerate Key Alert | ALZ_activityLAWKeyRegen | [deploy-activitylog-LAWorkspace-ReGen.json](../../../../services/OperationalInsights/workspaces/Deploy-ActivityLog-LAWorkspace-KeyRegen.json) | deployIfNotExists |

Expand Down Expand Up @@ -211,6 +213,11 @@ This initiative deploys Azure Monitor Baseline Alerts to monitor Web Services su
| Deploy App Service Plan Memory Percentage Alert | ALZ_WSFMemoryPercentage | [Deploy-WSF-MemoryPercentage-Alert.json](../../../../services/Web/serverFarms/Deploy-WSF-MemoryPercentage-Alert.json) | deployIfNotExists |
| Deploy App Service Plan Disk Queue Length Alert | ALZ_WSFDiskQueueLength | [Deploy-WSF-DiskQueueLength-Alert.json](../../../../services/Web/serverFarms/Deploy-WSF-DiskQueueLength-Alert.json) | deployIfNotExists |
| Deploy App Service Plan Http Queue Length Alert | ALZ_WSFHttpQueueLength | [Deploy-WSF-HttpQueueLength-Alert.json](../../../../services/Web/serverFarms/Deploy-WSF-HttpQueueLength-Alert.json) | deployIfNotExists |
| Deploy LA Workspace Daily Cap Limit Reached Alert | ALZ_LAWorkspaceDailyCapLimitReached | [Deploy_LAWorkspace_DailyCapLimitReached_Alert.json](../../../../services/OperationalInsights/workspaces/Deploy-ActivityLog-LAWorkspace-DailyCapLimitReached-Alert.json) | deployIfNotExists |
| Deploy Activity Log LA Workspace Delete Alert | ALZ_activityLAWDelete | [deploy-activitylog-LAWorkspace-Del.json](../../../../services/OperationalInsights/workspaces/Deploy-ActivityLog-LAWorkspace-Del.json) | deployIfNotExists |
| Deploy Activity Log LA Workspace Regenerate Key Alert | ALZ_activityLAWKeyRegen | [deploy-activitylog-LAWorkspace-ReGen.json](../../../../services/OperationalInsights/workspaces/Deploy-ActivityLog-LAWorkspace-KeyRegen.json) | deployIfNotExists |
| Deploy Application Insights Throttling Limit Reached Alert (Preview) | ALZ_AppInsightsThrottlingLimitReached_Alert | [Deploy-AppInsightsThrottlingLimit-Alert.json](../../../../services/Insights/components/Deploy-AppInsightsThrottlingLimit-Alert.json) | deployIfNotExists |
| Deploy Activity Log Application Insights Delete Alert (Preview) | ALZ_activityAppInsightsDelete | [Deploy-ActivityLog-AppInsights-Del.json](../../../../services/Insights/components/Deploy-ActivityLog-AppInsights-Del.json) | deployIfNotExists |

## Hybrid VM initiative

Expand Down
Loading

0 comments on commit db1ff22

Please sign in to comment.