Back to controls

Ensure Diagnostic Setting captures appropriate categories

Prerequisite: A Diagnostic Setting must exist. If a Diagnostic Setting does not exist, the navigation and options within this recommendation will not be available.

Category

Controls

Low

Applies to

Microsoft Azure

Coverage

null controls, 1 queries

Asset types

1 covered

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

  1. Go to Monitor
  2. Select Activity log
  3. Select Export Activity Logs
  4. Select the subscription your want from the drop-down menu
  5. Select + Add diagnostic setting
  6. Enter a name for the new Diagnostic Setting
  7. Under Logs, check the following categories: Administrative, Security, Alert, and Policy
  8. Under Destination details, check the preferred destination(s) for logs and fill in all details
  9. 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

  1. https://learn.microsoft.com/en-us/azure/azure-monitor/platform/diagnostic-settings
  2. https://learn.microsoft.com/en-us/azure/azure-monitor/samples/resource-manager-diagnostic-settings
  3. https://learn.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-logging-threat-detection#lt-3-enable-logging-for-security-investigation
  4. https://learn.microsoft.com/en-us/cli/azure/monitor/diagnostic-settings?view=azure-cli-latest
  5. [https://learn.microsoft.com/en-us/powershell/module/az.monitor/new-azsubscriptiondiagnosticsetting?view=azps-9.2.0]

Multiple Remediation Paths

Azure

SERVICE-WIDE (RECOMMENDED when many resources are affected): Assign Azure Policy initiatives at management group/subscription scope and trigger remediation tasks.

az policy assignment create --name <assignment-name> --scope /subscriptions/<subscription-id> --policy-set-definition <initiative-id>
az policy remediation create --name <remediation-name> --policy-assignment <assignment-id>

ASSET-LEVEL: Apply the resource-specific remediation steps above to the listed non-compliant resources.

PREVENTIVE: Embed Azure Policy checks into landing zones and IaC workflows to block or auto-remediate drift.

References for Service-Wide Patterns

  • Azure Policy overview: https://learn.microsoft.com/en-us/azure/governance/policy/overview
  • Azure Policy remediation: https://learn.microsoft.com/en-us/azure/governance/policy/how-to/remediate-resources
  • Azure Policy initiative structure: https://learn.microsoft.com/en-us/azure/governance/policy/concepts/initiative-definition-structure

Operational Rollout Workflow

Use this sequence to reduce risk and avoid repeated drift.

1. Contain at Service-Wide Scope First (Recommended)

  • Azure: assign policy initiatives at management group/subscription scope and run remediation tasks.
az policy assignment create --name <assignment-name> --scope /subscriptions/<subscription-id> --policy-set-definition <initiative-id>
az policy remediation create --name <remediation-name> --policy-assignment <assignment-id>

2. Remediate Existing Affected Assets

  • Execute the control-specific Console/CLI steps documented above for each flagged resource.
  • Prioritize internet-exposed and production assets first.

3. Validate and Prevent Recurrence

  • Re-scan after each remediation batch.
  • Track exceptions with owner and expiry date.
  • Add preventive checks in IaC/CI pipelines.

Query logic

These are the stored checks tied to this control.

Diagnostic Setting captures appropriate categories

Connectors

Microsoft Azure

Covered asset types

SubscriptionDiagnosticSettings

Expected check: eq []

{subscriptionDiagnosticSettings(where:{logSettings_SOME:{category_IN:["Administrative","Alert","Policy","Security"],enabled:false}},){...AssetFragment}}
Cyscale Logo
Cyscale is an agentless cloud-native application protection platform (CNAPP) that automates the contextual analysis of cloud misconfigurations, vulnerabilities, access, and data, to provide an accurate and actionable assessment of risk.

Stay connected

Receive new blog posts and product updates from Cyscale

By clicking Subscribe, I agree to Cyscale’s Privacy Policy


© 2026 Cyscale Limited

LinkedIn icon
Twitter icon
Facebook icon
crunch base icon
angel icon