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

Monitor disable parameters #246

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
91fe480
Allowing for monitordisable parameter flexibility
Brunoga-MS May 9, 2024
2d36813
Updating policy and policyDefinition version
Brunoga-MS May 9, 2024
4bf2584
updating existenceCondition
Brunoga-MS May 9, 2024
b7021c6
testing existingConditions
Brunoga-MS May 9, 2024
6d0e5c0
updating default value format
Brunoga-MS May 9, 2024
71cf616
testing new policyrule
Brunoga-MS May 11, 2024
91506f7
Exposed MonitorDisable parameter with values
Brunoga-MS May 17, 2024
9c4a114
Fixed parameter reference for checking value
Brunoga-MS May 17, 2024
660f2b1
Fixed wrong parameter reference in Deploy_activitylog_LAWorkspace_Delete
Brunoga-MS May 17, 2024
4fa6a5d
Fixed display name for params in Deploy_activitylog_LAWorkspace_Delete
Brunoga-MS May 17, 2024
abbde93
Added MonitorDisable params to Connectivity, Identity and LZ
Brunoga-MS May 17, 2024
fe7982d
Added MonitorDisabled params to other policydefinitions
Brunoga-MS May 17, 2024
9fbdcaf
Added MonitorDisabled params to some other policyDefinitions
Brunoga-MS May 17, 2024
41310a5
Fixed issue with param file and bicep template
Brunoga-MS May 17, 2024
1a5f394
Updated policySetDefinitions version
Brunoga-MS May 17, 2024
ad51eca
Removed duplicate params in the Servicehealth policySetDefinitions
Brunoga-MS May 17, 2024
21ea6e1
Removed unnecessary comma in Deploy_Suppression_AlertProcessing_Rule
Brunoga-MS May 17, 2024
1cd9468
Renamed ALZMonitorDisabled into MonitorDisabled in policySetDefinitions
Brunoga-MS May 17, 2024
c251e54
Renamed param
Brunoga-MS May 17, 2024
9a0334d
Added params to the params file
Brunoga-MS May 17, 2024
3039839
Adding effect to some policies
Brunoga-MS May 18, 2024
96dd327
updating default effect for activityKVDeletePolicyEffect in LZ policy…
Brunoga-MS May 18, 2024
72c9321
Added tags to disable monitoring to all policyDefinitions and policyD…
Brunoga-MS May 20, 2024
88ea9dc
Added missing param definition
Brunoga-MS May 20, 2024
9aa0a12
Added missing param to other files
Brunoga-MS May 20, 2024
25e8c7f
Fixed policyRule condition check for MonitorDisableTagValues
Brunoga-MS May 20, 2024
7e8375c
Added missing MonitorDisabletagNames tag to other files
Brunoga-MS May 20, 2024
68e009f
Added missing monitor tags to other alerts
Brunoga-MS May 20, 2024
ac24ec0
removed monitordisable* tags from VM alerts
Brunoga-MS May 20, 2024
2474ac9
Updated policy.json file
Brunoga-MS May 20, 2024
a11d323
Removed unnecessary monitordisable tag from VM heartbeat alert
Brunoga-MS May 20, 2024
2327cf3
Added missing policyEffect parameter
Brunoga-MS May 20, 2024
e7a950b
Merge branch 'Azure:main' into monitorDisableParameters
Brunoga-MS May 20, 2024
45e4758
Updated policy versions
Brunoga-MS May 20, 2024
b700a2a
Added missing params to the params file
Brunoga-MS May 20, 2024
1bedf41
Aligned and optimized policy.bicep, alzArm and alzArm.params files
Brunoga-MS May 22, 2024
c444d7a
Adding MonitorDisabled to some VM alerts (cpu and datadiskReadLatency)
Brunoga-MS May 22, 2024
e38879b
Aligning unrelated files to what recently committed to Main
Brunoga-MS May 30, 2024
ad067c7
removing monitordisable feature for VMs
Brunoga-MS May 30, 2024
365e8da
finished aligning with Main
Brunoga-MS May 30, 2024
bb92913
Added monitorDisable params to the variables
Brunoga-MS May 30, 2024
35c54b7
Renamed MonitorDisabled parameter into ALZMonitorDisable
Brunoga-MS May 31, 2024
0a0c45b
Added HybridVM DINE
Brunoga-MS May 31, 2024
4fcb46d
Added RG and UAMI templates
Brunoga-MS May 31, 2024
4c882d9
Added MonitorDisabled params to HybribVM
Brunoga-MS May 31, 2024
1d93353
Added MonitorDisable params to policyDefinitions
Brunoga-MS May 31, 2024
a4b98ad
Defined MonitorDisabled params in policy definitions
Brunoga-MS May 31, 2024
14c9aa5
Added MonitorDisabled to HybridVM CPU alert
Brunoga-MS May 31, 2024
7ca8afc
Parametrized MonitorDisabled param name and value in the query
Brunoga-MS May 31, 2024
e13df9e
Fixed syntax in query
Brunoga-MS Jun 1, 2024
31c28e5
added UAMI params to dine for Hybrid VM CPU Alert
Brunoga-MS Jun 1, 2024
06b8955
Adding the monitorDisable tag to all HybridVM alerts
Brunoga-MS Jun 5, 2024
8f71e5e
Renamed policyDefinitions which are not used
Brunoga-MS Jun 5, 2024
18bf89f
added UAMI as existence criteria on hybridVM disconnected
Brunoga-MS Jun 5, 2024
35ead8f
removed existenceCondition
Brunoga-MS Jun 5, 2024
fea79ef
putting existence criteria back
Brunoga-MS Jun 5, 2024
a0a3838
removing existenceCondition
Brunoga-MS Jun 5, 2024
365264b
Added the existenceCondition, MonitorDisable parameters and UAMI para…
Brunoga-MS Jun 6, 2024
8fedf0f
Aligned default value for alertResourceGroupTags
Brunoga-MS Jun 6, 2024
da06182
Aligning template and param file with latest release
Brunoga-MS Jun 6, 2024
36b3441
fixed formatting
Brunoga-MS Jun 6, 2024
ba08a1c
Removed DiskToInclude and NetworkInterfaceToInclude and passed only t…
Brunoga-MS Jun 7, 2024
233b8ea
Removed unnecessary parameter left by mistake
Brunoga-MS Jun 7, 2024
8da96a5
Updated policies.json
Brunoga-MS Jun 7, 2024
0fe83bd
Aligned the cleanup script
Brunoga-MS Jun 7, 2024
ecf88a2
Added missing computerToInclude to heartbeat alerts
Brunoga-MS Jun 7, 2024
bfb9155
Added paramter to be passed to LandingZone assignment
Brunoga-MS Jun 7, 2024
623ebdf
Prepared with splitted policies.json file
Brunoga-MS Jun 12, 2024
14d0a87
Fixing UAMI alias in existenceConditions and operator for disk latenc…
Brunoga-MS Jun 13, 2024
497796c
Updating policies*.json
Brunoga-MS Jun 13, 2024
87f6916
Fixed formatting in HybridVmDataDiskReadlatency
Brunoga-MS Jun 13, 2024
8fc3834
Fixed wrong query syntax
Brunoga-MS Jun 13, 2024
34e7bed
Fixed wrong query syntax in Azure VM alerts
Brunoga-MS Jun 13, 2024
d2ebb93
Fixed wrong HB query syntax in both Azure and Hybrid VMs
Brunoga-MS Jun 13, 2024
f315a71
Fixed template for policySetdefinition by adding the necessary missin…
Brunoga-MS Jun 13, 2024
27fa3f9
Fixed wrong parameter reference in resourceId function for both Hybri…
Brunoga-MS Jun 13, 2024
969bf87
Changed from resourceId to concat
Brunoga-MS Jun 13, 2024
c98406e
Changed from resourceId() to concat() function on all Hybrid alerts
Brunoga-MS Jun 13, 2024
4f294c7
Changed from resourceId() to concat() function in all Azure VM alerts
Brunoga-MS Jun 13, 2024
beab905
Fixed CUA deployment strings by adding the separator
Brunoga-MS Jun 13, 2024
46ab241
Fixed syntax in parameter file
Brunoga-MS Jun 13, 2024
f0aa9b6
Fixed tag-based exclusion condition on hybrid disconnected alerts
Brunoga-MS Jun 13, 2024
530fff0
reduced default value for HybridVMDisconnectedAlertDaysThreshold from…
Brunoga-MS Jun 13, 2024
4c4885b
Created a new cleanup script to manage breaking change with parameters
Brunoga-MS Jun 13, 2024
ca53a33
Added role assignment removal back
Brunoga-MS Jun 13, 2024
6c03017
formatting indentation
Brunoga-MS Jun 14, 2024
a1afbaa
Aligned policyDefinitions version
Brunoga-MS Jun 14, 2024
e481df4
Refactor ALZMonitorDisable to ALZMonitorDisableTagName
Brunoga-MS Jun 14, 2024
cb7a358
Merge branch 'main' of https://github.com/azure/azure-monitor-baselin…
Brunoga-MS Jun 14, 2024
ee8f985
Refactor ALZMonitorDisable to ALZMonitorDisableTagName
Brunoga-MS Jun 14, 2024
4d27571
Updated MonitorDisable documentation
Brunoga-MS Jun 14, 2024
4f1d05a
Refactor policy loading for improved performance
Brunoga-MS Jun 14, 2024
e1f4044
Refactor ALZMonitorDisable to ALZMonitorDisableTagName
Brunoga-MS Jun 14, 2024
29876ee
Refactor ALZMonitorDisable to ALZMonitorDisableTagName
Brunoga-MS Jun 14, 2024
ab97ef6
Refactor ALZMonitorDisable to ALZMonitorDisableTagName
Brunoga-MS Jun 14, 2024
61b6793
Refactor ALZMonitorDisable to ALZMonitorDisableTagName
Brunoga-MS Jun 14, 2024
4217987
Refactor ALZMonitorDisable to ALZMonitorDisableTagName
Brunoga-MS Jun 14, 2024
8b8961c
Refactor ALZMonitorDisable to ALZMonitorDisableTagName
Brunoga-MS Jun 14, 2024
7c656c0
Refactor ALZMonitorDisable to ALZMonitorDisableTagName
Brunoga-MS Jun 14, 2024
1f32358
Refactor ALZMonitorDisable to ALZMonitorDisableTagName
Brunoga-MS Jun 14, 2024
7cbb6aa
Fixed MonitorDisableTagName displayname
Brunoga-MS Jun 17, 2024
606652c
Formatter
Brunoga-MS Jun 17, 2024
0b5c0d5
Formatting
Brunoga-MS Jun 21, 2024
09ca131
Merge remote-tracking branch 'origin/main' into pr/Brunoga-MS/246
arjenhuitema Jul 1, 2024
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
19 changes: 14 additions & 5 deletions docs/content/patterns/alz/Disabling-Policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@ The PolicyEffect parameter is used for the configuration of the effect of the Po

## MonitorDisable parameter

It´s also possible to exclude certain resources from being monitored. You may not want to monitor pre-production or dev environments. The MonitorDisable parameter contains the Tag name to determine whether a resource should be included. By default, creating the tag MonitorDisable with value "true" will prevent deployment of alert rules on those resources. This is easily adjusted to use existing tags, for example you could configure the parameter with the tag name "Environment" and tell it to deploy only if the tag value equals "prod", or when the tag isnt equal to "dev". Currently only the tag name is a parameter, other changes require minor changes in the code.
It´s also possible to exclude certain resources from being monitored. You may not want to monitor pre-production or dev environments. The MonitorDisable parameter contains the tag name and tag value to determine whether a resource should be included. By default, creating the tag MonitorDisable with value "true" will prevent deployment of alert rules on those resources. This can be easily adjusted to use existing tags and tag values. For example you could configure the parameters with the tag name ***Environment*** and tag value of ***Production*** or ***Test*** or ***Sandbox*** or all of them to exclude resources in these environments (see the sample parameter screenshot).

![MonitorDisable* parameters](../media/MonitorDisableParams.png)

This will deploy policy definitions which will only be evaluated and remediated if the tag value(s) are not included in the list you provided.

### How it works

The policyRule only continues if "allOff" is true. Meaning, the deployment will continue as long as the MonitorDisable tag doesn't exist or doesn't hold the value "true". When the tag holds "true", the "allOff" will return "false" as "notEquals": "true" is no longer satisfied, causing the deployment to stop
The policyRule only continues if "allOff" is true. Meaning, the deployment will continue as long as the MonitorDisableTagName tag doesn't exist or doesn't hold the any of the values listed in the MonitorDisableTagValues parameter. When the tag holds one of the configured values, the "allOff" will return "false" as *"notIn": "[[parameters('MonitorDisableTagValues')]"* is no longer satisfied, causing the evaluation and hence the remediation to stop.

```json
"policyRule": {
Expand All @@ -107,9 +111,14 @@ The policyRule only continues if "allOff" is true. Meaning, the deployment will
"equals": "Microsoft.Automation/automationAccounts"
},
{
"field": "[[concat('tags[', parameters('MonitorDisable'), ']')]",
"notEquals": "true"
"field": "[[concat('tags[', parameters('MonitorDisableTagName'), ']')]",
"notIn": "[[parameters('MonitorDisableTagValues')]"
}
]
}
},
```

Given the different resource scope that this method can be applied to, we made it working a little bit different when it comes to log-based alerts. For instance, the virtual machine alerts are scoped to subscription and tagging the subcription would result in disabling all the policies targeted at it.
For this reason, and thanks to the new **Bring Your Own User Assigned Managed Identity (BYO UAMI)*** included in the [2024-06-05](../../Whats-New#2024-06-05) release and to the ability to query Azure resource Graph using Azure Monitor (see [Quickstart: Create alerts with Azure Resource Graph and Log Analytics](https://learn.microsoft.com/en-us/azure/governance/resource-graph/alerts-query-quickstart?tabs=azure-resource-graph)), it is now possible to disable individual alerts for both Azure and hybrid virtual machines after they are created. We got requests to stop alerting fro virtual machines that were off for maintenance and this enhancement came up just in time.

Should you need to disable the alerts for your virtual machines after they are created, just make sure you tag the relevant resources accordingly. The alert queries have been modified to look at resource properties in [Azure Resource Graph](https://learn.microsoft.com/en-us/azure/governance/resource-graph/overview). If the resource contains the given tag name and tag value, it is made part of an exclusion list, so alerts will not be generated for them. This behavior allows you to dinamically and rapidly exclude the necessary resources from being alerted without the need of deleteing the alert, tag the resource and run the remediation again.
2 changes: 1 addition & 1 deletion docs/content/patterns/alz/Monitoring-and-Alerting.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ With a **centralized** approach to alerting a central Action Group is used for a

Metric alerts are deployed with resources (same resource group) and platform alerts like Service Health / Activity are created in a dedicated resource group, in a subscription typically located in the Management platform management group. A single Alert Action Group in a subscription in the Management platform management group is configured with a central alerting email address, and Alert Processing Rules enabling filters and connecting alerts to the Alert Action Group.

As an example in the context of ALZ, a single centralized action group is deployed in the "AlzMonitoring-RG" resource group in a subscription in the Management platform management group.
As an example in the context of ALZ, a single centralized action group is deployed in the "rg-amba-monitoring-001" resource group in a subscription in the Management platform management group.

### Decentralized

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Updating from release 2024-06-05
geekdocCollapseSection: true
weight: 97
---
{{< hint type=Important >}}
***Updating to release from release [2024-06-05](../../Whats-New#2024-06-05) or from previous releases, contains a breaking change. To perform the update, it's required to remove previously deployed policy definitions, policy set definitions, policy assignments and role assignments. As part of this release we made a script available to clean all the necessary items. <ins>***It's strongly recommended that you test the script thoroughly before running on production environment. It isn't necessary to remove alert definitions that will continue to work in the meantime.***</ins>
{{< /hint >}}

# Pre update actions

Before updating to release [2024-06-30](../../Whats-New#2024-06-30), it's required to remove existing policy definitions, policy set definitions, policy assignments and role assignments. This action is required because of a breaking change caused by the redefinition of some parameters, which allows for more flexibility in disabling the policy remediation or, in some cases, the alerts. Unfortunately not all the alerts can be disabled after creation; only log-based alerts can be. Even if disabling the effect of policy was already possible in AMBA-ALZ, with this release we made sure that all the policies will honor both the ***PolicyEffect*** and the ***MonitorDisable*** parameters.

In particular, the *MonitorDisable* feature has been redesigned to allow customer to specify they own existing tag and tag value instead of forcing a hard coded one. Given the ALZ guidance and the best practice of having a consistent tagging definition, it's only allowed to one parameter name fo r the entire deployment. Instead, parameter value can be different. You can specify an array of values assigned to the same parameter. For instance, you have the ```Environment``` tag name consistently applied to several environments, saying ```Production```, ```Test```, ```Sandbox```, and so on and you want to disable alerts for resources, which are in both ```Test``` and ```Sandbox```. Now it's possible by just configuring the parameters for tag name and tag values as reported in the sample screenshot (these are the default values) below:

![MonitorDisable* parameters](../../media/MonitorDisableParams.png)

Complete description of this new/redesigned feature can be found in the [MonitorDisable parameter](../../Disabling-Policies#monitordisable-parameter) paragraph inside the [Disabling Policies](../../Disabling-Policies) page.

Once the policy definitions, policy set definitions, policy assignments and role assignments are removed and the deployment is completed, the execution of [Policy remediation](../../deploy/Remediate-Policies) will ensure that the new alerts will be created accordingly.

To run the script, complete the following steps:

1. Open PowerShell
2. Install the **Az.ResourceGraph** module: `Install-Module Az.ResourceGraph` (if not present)
3. Change directories to the location of the **Start-AMBAPolicyInitiativesAndAssignmentsCleanup.ps1** script
4. Configure the ***$pseudoRootManagementGroup*** variable using the following command:

```powershell
$pseudoRootManagementGroup = "The pseudo root management group id parenting the identity, management and connectivity management groups"
```

1. Sign in to the Azure with the `Connect-AzAccount` command. The account you sign in as needs to have permissions to remove policy definitions, policy set definitions, policy assignments and role assignments at the desired Management Group scope.

2. Execute the script using one of the following options:

{{% include "PowerShell-ExecutionPolicy.md" %}}

**Generate a list of policy definitions, policy set definitions, policy assignments and role assignments resources which would be deleted by this script:**

```powershell
./Start-AMBAPolicyInitiativesAndAssignmentsCleanup.ps1 -pseudoRootManagementGroup $pseudoRootManagementGroup -ReportOnly
```

**Show output of what would happen if deletes executed:**

```powershell
./Start-AMBAPolicyInitiativesAndAssignmentsCleanup.ps1 -pseudoRootManagementGroup $pseudoRootManagementGroup -WhatIf
```

**Delete policy definitions, policy set definitions, policy assignments and role assignments resources deployed by the AMBA-ALZ pattern without prompting for confirmation:**

```powershell
./Start-AMBAPolicyInitiativesAndAssignmentsCleanup.ps1 -pseudoRootManagementGroup $pseudoRootManagementGroup -Force
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading