Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support CMK linked storage accounts #521

Merged
merged 24 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
804fa38
added checkWorkspaceAlertsStorageConfigured to all scheduled query al…
tgolovina Jan 30, 2025
93e52a0
tgolovina Jan 30, 2025
4bac656
fixed end of line
tgolovina Jan 31, 2025
9729b13
Merge branch 'main' of https://github.com/azure/azure-monitor-baselin…
tgolovina Jan 31, 2025
11dcbc1
Removed ComputersToInclude parametr
tgolovina Feb 5, 2025
226f8d3
removed all compute to include parameters
tgolovina Feb 7, 2025
0e7c159
bicep build
tgolovina Feb 7, 2025
7a2a77b
Merge branch 'Azure:main' into computerstoinclude_remove
tagolovina Feb 12, 2025
8248f42
Ffixed error VMDataDiskSpace
tgolovina Feb 20, 2025
71715be
fixed VMDataDiskSpace error
tgolovina Feb 20, 2025
172c9b9
discard changes from param file
tgolovina Feb 20, 2025
db1ff22
Merge branch 'main' of https://github.com/azure/azure-monitor-baselin…
tgolovina Feb 21, 2025
92d45cb
bicepbuild
tgolovina Feb 21, 2025
907af99
cmk documentation
tgolovina Feb 21, 2025
117235c
Fixing policy json files
Brunoga-MS Feb 22, 2025
4c4a2bc
fixing workflow script
Brunoga-MS Feb 22, 2025
2879ab2
Reverting policy build test to windows runner
Brunoga-MS Feb 22, 2025
d4789de
Adding warning messages
Brunoga-MS Feb 22, 2025
4dfc07d
Refactor warning messages in policy tests for clarity and consistency
Brunoga-MS Feb 22, 2025
d19acb1
Update warning message to check for null or empty default values in p…
Brunoga-MS Feb 23, 2025
cd2e4ad
Add "UAMIResourceId" to excluded policy parameters in tests
Brunoga-MS Feb 23, 2025
03544c4
Remove commented-out warning messages in policy tests for cleaner code
Brunoga-MS Feb 23, 2025
7359f5f
Update documentation for Customer-managed key in log search alerts an…
Brunoga-MS Feb 24, 2025
79dfd37
Hide the Customer-managed key documentation section in log search alerts
Brunoga-MS Feb 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/actions-pester/Test-ModifiedPolicies.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe 'UnitTest-ModifiedPolicies' {
BeforeAll {
Import-Module -Name $PSScriptRoot\PolicyPesterTestHelper.psm1 -Force -Verbose
Import-Module -Name $PSScriptRoot\PolicyPesterTestHelper.psm1 -Force # -Verbose

$ModifiedFiles = @(Get-PolicyFiles -DiffFilter "M")
if ($ModifiedFiles -ne $null) {
Expand Down Expand Up @@ -132,7 +132,7 @@ Describe 'UnitTest-ModifiedPolicies' {
$PolicyFile = Split-Path $_ -Leaf
$PolicyMetadataName = $PolicyJson.name
$ExcludePolicy = @()
$ExcludeParams = @("ALZManagementSubscriptionId", "BYOUserAssignedManagedIdentityResourceId")
$ExcludeParams = @("ALZManagementSubscriptionId", "BYOUserAssignedManagedIdentityResourceId", "UAMIResourceId")
if ($PolicyMetadataName -notin $ExcludePolicy) {
$PolicyParameters = $PolicyJson.properties.parameters
if ($PolicyParameters | Get-Member -MemberType NoteProperty) {
Expand All @@ -144,7 +144,7 @@ Describe 'UnitTest-ModifiedPolicies' {
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."
$PolicyParameters.$key.defaultValue | Should -Not -BeNullOrEmpty -Because "the [defaultValue] for parameter [$key] is empty."
}
}
}
Expand Down
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: ubuntu-latest
runs-on: windows-latest

steps:
- name: Check out repository
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Secure log search alert queries with Customer-managed key
geekdocCollapseSection: true
geekdocHidden: true
weight: 79
---

### In this page

> [Overview](../Customer_managed_key_for_log_search_alerts#overview) </br>
> [How this feature works](../Customer_managed_key_for_log_search_alerts#how-this-feature-works) </br>

## Overview

The query language used in Log Analytics is expressive and can contain sensitive information in comments, or in the query syntax. Despite all data and saved queries are encrypted at rest using Microsoft-managed keys (MMK), some organizations might require that such information is kept protected under Customer-managed key policy. For this reason, you need to save your queries encrypted with your key. Azure Monitor enables you to store saved queries and log search alerts encrypted with your key in your own Storage Account when linked to your workspace. Check guidance and considerations in the following article: [Azure Monitor customer-managed keys](https://learn.microsoft.com/en-us/azure/azure-monitor/logs/customer-managed-keys?tabs=portal).

![Alert Rule](../../media/cmk_alertrule.png)

## How this feature works

{{< hint type=Info >}}
**This feature is applicable only to log-search alerts.**
{{< /hint >}}

The **Require a workspace linked storage** option in the query alert rule controls whether this scheduled query rule should be stored in the customer's storage. To control this option in the AMBA-ALZ pattern, we use the ***checkWorkspaceAlertsStorageConfigured*** parameter with a **default value of 'false'**. More information in the following article: [Scheduled Query Rules](https://learn.microsoft.com/en-us/azure/templates/microsoft.insights/scheduledqueryrules?pivots=deployment-language-bicep)

To change the **checkWorkspaceAlertsStorageConfigured** flag to **'true'**, navigate to:

- [alzArm.param.json](https://github.com/azure/azure-monitor-baseline-alerts/blob/2025-02-05/patterns/alz/alzArm.param.json) for the latest release.
- [alzArm.param.json](https://github.com/azure/azure-monitor-baseline-alerts/blob/main/patterns/alz/alzArm.param.json) for the main branch.
- change parameters value where name contains *checkWorkspaceAlertsStorageConfigured* to *true*
![Parameter file](../../media/cmk_parameter.png)

{{< hint type=IMPORTANT >}}
An alert rule won't be created if the Log Analytics workspace doesn't have a configured linked storage account.
{{< /hint >}}

Enabling this feature without a linked storage account, will cause the remediation task to fail

![remediation task error](../../media/cmk_remediation_task_error.png)

with an error message similar to the following one:

![remediation task error message](../../media/cmk_remediation_task_error_message.png)

As consequence, <ins>***no alert rule for the given policy will be created***</ins> and the corresponding policy definition will show as ***Non-compliant***. See the image below

![Policy compliance](../../media/cmk_alert_rule_error.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading