Azure Diagnostic Settings Deleted

Identifies deletion of Azure diagnostic settings for a resource group that has not had this operation in the prior 7 days. Diagnostic settings send platform logs and metrics to Log Analytics, Event Hubs, or storage; removing them blinds monitoring and detection. This rule uses an ES|QL first-seen (new terms) approach keyed on the resource group so groups that constantly churn logging configuration are suppressed after the first occurrence, while a newly seen group still alerts.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/08/17"
  3integration = ["azure"]
  4maturity = "production"
  5updated_date = "2026/09/21"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies deletion of Azure diagnostic settings for a resource group that has not had this operation in the prior 7
 11days. Diagnostic settings send platform logs and metrics to Log Analytics, Event Hubs, or storage; removing them blinds
 12monitoring and detection. This rule uses an ES|QL first-seen (new terms) approach keyed on the resource group so groups
 13that constantly churn logging configuration are suppressed after the first occurrence, while a newly seen group still
 14alerts.
 15"""
 16false_positives = [
 17    """
 18    Infrastructure-as-code, CI/CD, and platform automation (for example Crossplane, Terraform, ARM/Bicep) commonly
 19    delete diagnostic settings during environment teardown or redeploy. The first occurrence per resource group in 7
 20    days will alert; groups that are rebuilt often will then go quiet.
 21    """,
 22    """
 23    Microsoft-owned resource providers (for example Azure Cosmos DB networking) may remove diagnostic settings as part
 24    of private-endpoint or control-plane lifecycle. Confirm the actor, app, and whether the group is non-production
 25    before treating the event as malicious.
 26    """,
 27]
 28from = "now-7d"
 29language = "esql"
 30license = "Elastic License v2"
 31name = "Azure Diagnostic Settings Deleted"
 32note = """## Triage and analysis
 33
 34### Investigating Azure Diagnostic Settings Deleted
 35
 36Azure Diagnostic Settings are crucial for monitoring and logging platform activities, sending data to various destinations for analysis. Adversaries may delete these settings to hinder detection and analysis of their activities, effectively evading defenses. The detection rule identifies such deletions by aggregating successful `DIAGNOSTICSETTINGS/DELETE` operations over a 7-day lookback and alerting when a resource group's first delete in that window falls in the current schedule interval.
 37
 38### Possible investigation steps
 39
 40- Identify the user or service principal responsible for the deletion from `Esql.principal_id_values` and `Esql.principal_type_values`. Resolve the human-readable name from `Esql.initiated_by_user_values`.
 41- If this is a service principal, determine which application is associated with it via `Esql.appid_values` and examine credential use with authentication sources to identify potential compromise.
 42- Examine the resource group (`azure.resource.group`) and subscription (`Esql.subscription_id_values`) context to understand the scope of the deletion and whether it affects critical resources.
 43- Check `Esql.first_time_seen` to determine when the diagnostic settings were removed and correlate this with other security events or alerts around the same time. Pivot on `Esql.session_id_values`, `Esql.unique_token_id_values`, and `Esql.correlation_id_values`.
 44- Investigate the affected resources by identifying which diagnostic settings were deleted (`Esql.resource_name_values`, `Esql.resource_id_values`) and assess the potential impact on monitoring and logging capabilities.
 45- Review any recent changes or activities performed by the identified user or service principal to determine if there are other suspicious actions that might indicate malicious intent. Review `Esql.role_values` and `Esql.role_assignment_id_values`.
 46- Assess the current security posture by ensuring that diagnostic settings are reconfigured and that logging and monitoring are restored to maintain visibility into platform activities.
 47
 48### False positive analysis
 49
 50- Examine the service principal or user account involved in the deletion to determine if it is part of an automated process or legitimate administrative activity.
 51- Automated scripts or tools used for managing Azure resources might delete diagnostic settings as part of their operation. Review and whitelist these scripts if they are verified as non-threatening.
 52- Changes in organizational policy or compliance requirements could lead to legitimate deletions. Confirm with relevant teams if such policy changes are in effect.
 53- Test environments often undergo frequent configuration changes, including the deletion of diagnostic settings. Consider excluding these environments from the rule or adjusting the rule to account for their unique behavior.
 54- Ensure that any third-party integrations or services with access to Azure resources are reviewed, as they might inadvertently delete diagnostic settings during their operations.
 55
 56### Response and remediation
 57
 58- Immediately isolate affected Azure resources to prevent further unauthorized changes or deletions. This may involve temporarily restricting access to the affected subscriptions or resource groups.
 59- Review the Azure activity logs to identify the source of the deletion request, including the user account, service principal and IP address involved. This will help determine if the action was authorized or malicious.
 60- Recreate the deleted diagnostic settings as soon as possible to restore logging and monitoring capabilities. Ensure that logs are being sent to secure and appropriate destinations.
 61- Conduct a thorough investigation of the user account or service principal involved in the deletion. If the account is compromised, reset credentials, and review permissions to ensure they are appropriate and follow the principle of least privilege.
 62- Escalate the incident to the security operations team for further analysis and to determine if additional resources or expertise are needed to address the threat.
 63- Implement additional monitoring and alerting for similar deletion activities to ensure rapid detection and response to future attempts.
 64- Review and update access controls and policies related to diagnostic settings to prevent unauthorized deletions, ensuring that only trusted and necessary personnel have the ability to modify these settings.
 65"""
 66references = [
 67    "https://docs.microsoft.com/en-us/azure/azure-monitor/platform/diagnostic-settings",
 68    "https://www.microsoft.com/en-us/security/blog/2025/10/20/inside-the-attack-chain-threat-activity-targeting-azure-blob-storage/",
 69]
 70risk_score = 47
 71rule_id = "5370d4cd-2bb3-4d71-abf5-1e1d0ff5a2de"
 72severity = "medium"
 73tags = [
 74    "Domain: Cloud",
 75    "Data Source: Azure",
 76    "Data Source: Azure Activity Logs",
 77    "Use Case: Threat Detection",
 78    "Tactic: Defense Evasion",
 79    "Resources: Investigation Guide",
 80    "Noise: Low",
 81    "Performance: Normal",
 82    "Profile: Recommended",
 83    "Rule Type: ES|QL",
 84    "Platform: Azure",
 85    "Service: Azure Resource Manager",
 86]
 87timestamp_override = "event.ingested"
 88type = "esql"
 89
 90query = '''
 91FROM logs-azure.activitylogs-*
 92| WHERE data_stream.dataset == "azure.activitylogs"
 93    AND event.action == "MICROSOFT.INSIGHTS/DIAGNOSTICSETTINGS/DELETE"
 94    AND event.outcome IN ("success", "Success")
 95    AND azure.resource.group IS NOT NULL
 96| STATS Esql.first_time_seen = MIN(@timestamp),
 97        Esql.last_time_seen = MAX(@timestamp),
 98        Esql.event_count = COUNT(*),
 99        Esql.event_action_values = VALUES(event.action),
100        Esql.resource_name_values = VALUES(azure.resource.name),
101        Esql.resource_id_values = VALUES(azure.resource.id),
102        Esql.resource_provider_values = VALUES(azure.resource.provider),
103        Esql.principal_id_values = VALUES(azure.activitylogs.identity.authorization.evidence.principal_id),
104        Esql.principal_type_values = VALUES(azure.activitylogs.identity.authorization.evidence.principal_type),
105        Esql.initiated_by_user_values = VALUES(azure.activitylogs.identity.claims_initiated_by_user.name),
106        Esql.appid_values = VALUES(azure.activitylogs.identity.claims.appid),
107        Esql.session_id_values = VALUES(azure.activitylogs.identity.claims.sid),
108        Esql.unique_token_id_values = VALUES(azure.activitylogs.identity.claims.uti),
109        Esql.correlation_id_values = VALUES(azure.correlation_id),
110        Esql.role_values = VALUES(azure.activitylogs.identity.authorization.evidence.role),
111        Esql.role_assignment_id_values = VALUES(azure.activitylogs.identity.authorization.evidence.role_assignment_id),
112        Esql.role_assignment_scope_values = VALUES(azure.activitylogs.identity.authorization.evidence.role_assignment_scope),
113        Esql.source_ip_values = VALUES(source.ip),
114        Esql.source_country_values = VALUES(source.geo.country_name),
115        Esql.source_as_number_values = VALUES(source.`as`.number),
116        Esql.subscription_id_values = VALUES(azure.subscription_id)
117        BY azure.resource.group
118// new terms emulation: fire when this resource group's first_seen falls in the current interval
119// (schedule + ingest-lag buffer), i.e. it was absent from the rest of the 7-day window
120| EVAL Esql.recent_minutes = DATE_DIFF("minute", Esql.first_time_seen, NOW())
121| WHERE Esql.recent_minutes <= 10
122| KEEP azure.*, Esql.*
123'''
124
125
126[[rule.threat]]
127framework = "MITRE ATT&CK"
128[[rule.threat.technique]]
129id = "T1562"
130name = "Impair Defenses"
131reference = "https://attack.mitre.org/techniques/T1562/"
132[[rule.threat.technique.subtechnique]]
133id = "T1562.001"
134name = "Disable or Modify Tools"
135reference = "https://attack.mitre.org/techniques/T1562/001/"
136
137[[rule.threat.technique.subtechnique]]
138id = "T1562.008"
139name = "Disable or Modify Cloud Logs"
140reference = "https://attack.mitre.org/techniques/T1562/008/"
141
142
143
144[rule.threat.tactic]
145id = "TA0005"
146name = "Defense Evasion"
147reference = "https://attack.mitre.org/tactics/TA0005/"
148
149[rule.investigation_fields]
150field_names = [
151    "azure.resource.group",
152    "Esql.first_time_seen",
153    "Esql.event_action_values",
154    "Esql.source_ip_values",
155    "Esql.principal_type_values",
156    "Esql.role_assignment_scope_values",
157    "Esql.appid_values",
158    "Esql.resource_name_values",
159    "Esql.resource_provider_values",
160    "Esql.principal_id_values",
161    "Esql.initiated_by_user_values",
162    "Esql.resource_id_values",
163    "Esql.session_id_values",
164    "Esql.unique_token_id_values",
165    "Esql.correlation_id_values",
166    "Esql.role_values",
167    "Esql.role_assignment_id_values",
168    "Esql.source_country_values",
169    "Esql.source_as_number_values",
170    "Esql.subscription_id_values",
171]

Triage and analysis

Investigating Azure Diagnostic Settings Deleted

Azure Diagnostic Settings are crucial for monitoring and logging platform activities, sending data to various destinations for analysis. Adversaries may delete these settings to hinder detection and analysis of their activities, effectively evading defenses. The detection rule identifies such deletions by aggregating successful DIAGNOSTICSETTINGS/DELETE operations over a 7-day lookback and alerting when a resource group's first delete in that window falls in the current schedule interval.

Possible investigation steps

  • Identify the user or service principal responsible for the deletion from Esql.principal_id_values and Esql.principal_type_values. Resolve the human-readable name from Esql.initiated_by_user_values.
  • If this is a service principal, determine which application is associated with it via Esql.appid_values and examine credential use with authentication sources to identify potential compromise.
  • Examine the resource group (azure.resource.group) and subscription (Esql.subscription_id_values) context to understand the scope of the deletion and whether it affects critical resources.
  • Check Esql.first_time_seen to determine when the diagnostic settings were removed and correlate this with other security events or alerts around the same time. Pivot on Esql.session_id_values, Esql.unique_token_id_values, and Esql.correlation_id_values.
  • Investigate the affected resources by identifying which diagnostic settings were deleted (Esql.resource_name_values, Esql.resource_id_values) and assess the potential impact on monitoring and logging capabilities.
  • Review any recent changes or activities performed by the identified user or service principal to determine if there are other suspicious actions that might indicate malicious intent. Review Esql.role_values and Esql.role_assignment_id_values.
  • Assess the current security posture by ensuring that diagnostic settings are reconfigured and that logging and monitoring are restored to maintain visibility into platform activities.

False positive analysis

  • Examine the service principal or user account involved in the deletion to determine if it is part of an automated process or legitimate administrative activity.
  • Automated scripts or tools used for managing Azure resources might delete diagnostic settings as part of their operation. Review and whitelist these scripts if they are verified as non-threatening.
  • Changes in organizational policy or compliance requirements could lead to legitimate deletions. Confirm with relevant teams if such policy changes are in effect.
  • Test environments often undergo frequent configuration changes, including the deletion of diagnostic settings. Consider excluding these environments from the rule or adjusting the rule to account for their unique behavior.
  • Ensure that any third-party integrations or services with access to Azure resources are reviewed, as they might inadvertently delete diagnostic settings during their operations.

Response and remediation

  • Immediately isolate affected Azure resources to prevent further unauthorized changes or deletions. This may involve temporarily restricting access to the affected subscriptions or resource groups.
  • Review the Azure activity logs to identify the source of the deletion request, including the user account, service principal and IP address involved. This will help determine if the action was authorized or malicious.
  • Recreate the deleted diagnostic settings as soon as possible to restore logging and monitoring capabilities. Ensure that logs are being sent to secure and appropriate destinations.
  • Conduct a thorough investigation of the user account or service principal involved in the deletion. If the account is compromised, reset credentials, and review permissions to ensure they are appropriate and follow the principle of least privilege.
  • Escalate the incident to the security operations team for further analysis and to determine if additional resources or expertise are needed to address the threat.
  • Implement additional monitoring and alerting for similar deletion activities to ensure rapid detection and response to future attempts.
  • Review and update access controls and policies related to diagnostic settings to prevent unauthorized deletions, ensuring that only trusted and necessary personnel have the ability to modify these settings.

References

Related rules

to-top