Skip to content

Commit 9983653

Browse files
authored
Merge pull request #224040 from EdB-MSFT/new-azmon-policies
New builtin polices to create diagnostic settings in Azure Monitor with deploy if not exits defaults
2 parents 6882ef7 + 7d26469 commit 9983653

18 files changed

+454
-17
lines changed

articles/azure-monitor/essentials/diagnostic-settings-policy.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
11
---
2-
title: Create diagnostic settings at scale using Azure Policy
3-
description: Use Azure Policy to create diagnostic settings in Azure Monitor to be created at scale as each Azure resource is created.
4-
author: rboucher
2+
title: Create diagnostic settings at scale using Azure policies and initiatives
3+
description: Use Azure Policy to create diagnostic settings in Azure Monitor at scale as each Azure resource is created.
4+
author: EdB-MSFT
55
ms.author: edbaynash
66
services: azure-monitor
77
ms.topic: conceptual
8-
ms.date: 05/09/2022
8+
ms.date: 02/25/2023
99
ms.reviewer: lualderm
1010
---
1111

12-
# Create diagnostic settings at scale using Azure Policy
13-
Since a [diagnostic settings](diagnostic-settings.md) needs to be created for each monitored Azure resource, Azure Policy can be used to automatically create a diagnostic setting as each resource is created. Each Azure resource type has a unique set of categories that need to be listed in the diagnostic setting. Because of this fact, each resource type requires a separate policy definition. Some resource types have built-in policy definitions that you can assign without modification. For other resource types, you need to create a custom definition.
1412

15-
With the addition of resource log category groups, you can now choose options that dynamically update as the log categories change. For more information, see [diagnostic settings sources](diagnostic-settings.md#sources) listed earlier in this article. All resource types have the "All" category. Some have the "Audit" category.
13+
# Create diagnostic settings at scale using Azure Policies and Initiatives
14+
15+
In order to monitor Azure resources, it's necessary to create [diagnostic settings](./diagnostic-settings.md) for each resource. This process can be difficult to manage when you have many resources. To simplify the process of creating and applying diagnostic settings at scale, use Azure Policy to automatically generate diagnostic settings for both new and existing resources.
16+
17+
Each Azure resource type has a unique set of categories listed in the diagnostic settings. Each resource type therefore requires a separate policy definition. Some resource types have built-in policy definitions that you can assign without modification. For other resource types, you can create a custom definition.
18+
19+
## Log category groups
20+
21+
Log category groups, group together similar types of logs. Category groups make it easy to refer to multiple logs in a single command. An **allLogs** category group exists containing all of the logs. There's also an **audit** category group that includes all audit logs. By using to a category group, you can define a policy that dynamically updates as new log categories are added to group.
1622

1723
## Built-in policy definitions for Azure Monitor
18-
There are two built-in policy definitions for each resource type: one to send to a Log Analytics workspace and another to send to an event hub. If you need only one location, assign that policy for the resource type. If you need both, assign both policy definitions for the resource.
24+
There are generally three built-in policy definitions for each resource type, corresponding to the three destinations to send diagnostics to:
25+
* Log Analytics workspaces
26+
* Azure Storage accounts
27+
* Event hubs
1928

20-
For example, the following image shows the built-in diagnostic setting policy definitions for Azure Data Lake Analytics.
29+
Assign the policies for the resource type according to which destinations you need.
2130

22-
![Partial screenshot from the Azure Policy Definitions page showing two built-in diagnostic setting policy definitions for Data Lake Analytics.](media/diagnostic-settings-policy/built-in-diagnostic-settings.png)
31+
A set of policies built-in policies and initiatives based on the audit log category groups have been developed to help you apply diagnostics settings with only a few steps. For more information, see [Enable Diagnostics settings by category group using built-in policies.](./diagnostics-settings-policies-deployifnotexists.md)
2332

24-
For a complete listof built-in policies for Azure Monitor, see [Azure Policy built-in definitions for Azure Monitor](../policy-reference.md)
33+
For a complete list of built-in policies for Azure Monitor, see [Azure Policy built-in definitions for Azure Monitor](../policy-reference.md)
2534

2635
## Custom policy definitions
27-
For resource types that don't have a built-in policy, you need to create a custom policy definition. You could do this manually in the Azure portal by copying an existing built-in policy and then modifying it for your resource type. It's more efficient, though, to create the policy programmatically by using a script in the PowerShell Gallery.
36+
For resource types that don't have a built-in policy, you need to create a custom policy definition. You could do create a new policy manually in the Azure portal by copying an existing built-in policy and then modifying it for your resource type. Alternatively, create the policy programmatically by using a script in the PowerShell Gallery.
2837

2938
The script [Create-AzDiagPolicy](https://www.powershellgallery.com/packages/Create-AzDiagPolicy) creates policy files for a particular resource type that you can install by using PowerShell or the Azure CLI. Use the following procedure to create a custom policy definition for diagnostic settings:
3039

@@ -84,7 +93,7 @@ By using initiative parameters, you can specify the workspace or any other detai
8493
![Screenshot that shows initiative parameters on the Parameters tab.](media/diagnostic-settings-policy/initiative-parameters.png)
8594

8695
## Remediation
87-
The initiative will apply to each virtual machine as it's created. A [remediation task](../../governance/policy/how-to/remediate-resources.md) deploys the policy definitions in the initiative to existing resources, so you can create diagnostic settings for any resources that were already created.
96+
The initiative will be applied to each virtual machine as it's created. A [remediation task](../../governance/policy/how-to/remediate-resources.md) deploys the policy definitions in the initiative to existing resources, so you can create diagnostic settings for any resources that were already created.
8897

8998
When you create the assignment by using the Azure portal, you have the option of creating a remediation task at the same time. See [Remediate non-compliant resources with Azure Policy](../../governance/policy/how-to/remediate-resources.md) for details on the remediation.
9099

@@ -96,15 +105,15 @@ When you create the assignment by using the Azure portal, you have the option of
96105

97106
When deploying a diagnostic setting, you receive an error message, similar to *Metric category 'xxxx' is not supported*. You may receive this error even though your previous deployment succeeded.
98107

99-
The problem occurs when using a Resource Manager template, REST API, Azure CLI, or Azure PowerShell. Diagnostic settings created via the Azure portal are not affected as only the supported category names are presented.
108+
The problem occurs when using a Resource Manager template, REST API, Azure CLI, or Azure PowerShell. Diagnostic settings created via the Azure portal aren't affected as only the supported category names are presented.
100109

101-
The problem is caused by a recent change in the underlying API. Metric categories other than 'AllMetrics' are not supported and never were except for a few specific Azure services. In the past, other category names were ignored when deploying a diagnostic setting. The Azure Monitor backend redirected these categories to 'AllMetrics'. As of February 2021, the backend was updated to specifically confirm the metric category provided is accurate. This change has caused some deployments to fail.
110+
The problem is caused by a recent change in the underlying API. Metric categories other than 'AllMetrics' aren't supported and never were except for a few specific Azure services. In the past, other category names were ignored when deploying a diagnostic setting. The Azure Monitor backend redirected these categories to 'AllMetrics'. As of February 2021, the backend was updated to specifically confirm the metric category provided is accurate. This change has caused some deployments to fail.
102111

103112
If you receive this error, update your deployments to replace any metric category names with 'AllMetrics' to fix the issue. If the deployment was previously adding multiple categories, only one with the 'AllMetrics' reference should be kept. If you continue to have the problem, contact Azure support through the Azure portal.
104113

105114
### Setting disappears due to non-ASCII characters in resourceID
106115

107-
Diagnostic settings do not support resourceIDs with non-ASCII characters (for example, Preproducción). Since you cannot rename resources in Azure, your only option is to create a new resource without the non-ASCII characters. If the characters are in a resource group, you can move the resources under it to a new one. Otherwise, you'll need to recreate the resource.
116+
Diagnostic settings don't support resourceIDs with non-ASCII characters (for example, Preproducción). Since you can't rename resources in Azure, your only option is to create a new resource without the non-ASCII characters. If the characters are in a resource group, you can move the resources under it to a new one. Otherwise, you'll need to recreate the resource.
108117

109118
## Next steps
110119

articles/azure-monitor/essentials/diagnostic-settings.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ Information on these newer features is included in this article.
4444
4545
## Sources
4646

47-
Here are the source options.
47+
There are three sources for diagnostic information:
48+
* Metrics
49+
* Resource Logs
50+
* Activity logs
4851

4952
### Metrics
5053

0 commit comments

Comments
 (0)