Overview
Prerequisite: A Diagnostic Setting must exist. If a Diagnostic Setting does not exist, the navigation and options within this recommendation will not be available.
The diagnostic setting should be configured to log the appropriate activities from the control/management plane.
Rationale
A diagnostic setting controls how the diagnostic log is exported. Capturing the diagnostic setting categories for appropriate control/management plane activities allows proper alerting.
Remediation guidance
From Azure Console
- Go to
Monitor - Select
Activity log - Select
Export Activity Logs - Select the subscription your want from the drop-down menu
- Select
+ Add diagnostic setting - Enter a name for the new Diagnostic Setting
- Under
Logs, check the following categories:Administrative,Security,Alert, andPolicy - Under
Destination details, check the preferred destination(s) for logs and fill in all details - Select
Save
Using Azure CLI
az monitor diagnostic-settings subscription create --subscription <subscriptionID> --name <diagnosticSettingsName> --location <location> <[--event-hub <eventHubID> --event-hub-auth-rule <eventHubAuthRuleID>] [--storage-account <storageAccountID>] [--workspace <logAnalyticsWorkspaceID>] --logs "[{category:Security,enabled:true},{category:Administrative,enabled:true},{category:Alert,enabled:true},{category:Policy,enabled:true}]"
Using Azure PowerShell
$logCategories = @();
$logCategories += New-AzDiagnosticSettingSubscriptionLogSettingsObject -Category Administrative -Enabled $true
$logCategories += New-AzDiagnosticSettingSubscriptionLogSettingsObject -Category Security -Enabled $true
$logCategories += New-AzDiagnosticSettingSubscriptionLogSettingsObject -Category Alert -Enabled $true
$logCategories += New-AzDiagnosticSettingSubscriptionLogSettingsObject -Category Policy -Enabled $true
New-AzSubscriptionDiagnosticSetting -SubscriptionId <subscriptionID> -Name <diagnosticSettingsName> <[-EventHubAuthorizationRule <eventHubAuthRuleID> -EventHubName <eventHubName>] [-StorageAccountId <storageAccountID>] [-WorkSpaceId <logAnalyticsWorkspaceID>] [-MarketplacePartner ID <fullARMMarketplaceResource ID>]> -Log $logCategories
Default Value
When the diagnostic setting is created using Azure Portal, by default no categories are selected.
References
- https://learn.microsoft.com/en-us/azure/azure-monitor/platform/diagnostic-settings
- https://learn.microsoft.com/en-us/azure/azure-monitor/samples/resource-manager-diagnostic-settings
- https://learn.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-logging-threat-detection#lt-3-enable-logging-for-security-investigation
- https://learn.microsoft.com/en-us/cli/azure/monitor/diagnostic-settings?view=azure-cli-latest
- [https://learn.microsoft.com/en-us/powershell/module/az.monitor/new-azsubscriptiondiagnosticsetting?view=azps-9.2.0]
Service-wide remediation
Recommended when many resources are affected: fix the platform baseline first so new resources inherit the secure setting, then remediate the existing flagged resources in batches.
Azure
Use management group or subscription Azure Policy assignments, remediation tasks where supported, landing-zone standards, and IaC modules so drift is prevented at scale.
Operational rollout
- Fix the baseline first at the account, subscription, project, cluster, or tenant scope that owns this control.
- Remediate the currently affected resources in batches, starting with internet-exposed and production assets.
- Re-scan and track approved exceptions with an owner and expiry date.
Query logic
These are the stored checks tied to this control.
Diagnostic Setting captures appropriate categories
Connectors
Covered asset types
Expected check: eq []
{subscriptionDiagnosticSettings(where:{logSettings_SOME:{category_IN:["Administrative","Alert","Policy","Security"],enabled:false}},){...AssetFragment}}
Microsoft Azure