Microsoft Defender Create
Synopsis
Creates custom alerts in Microsoft Defender for Endpoint using the CreateAlertByReference API, enabling external threat detection systems to integrate with Microsoft's endpoint security platform for centralized incident management and automated response capabilities.
Schema
- msdefender_create:
machine_id: <string>
severity: <string>
title: <string>
alert_description: <string>
recommended_action: <string>
category: <string>
report_id: <string>
tenant_id: <string>
client_id: <string>
client_secret: <string>
event_time: <string>
description: <text>
if: <script>
disabled: <boolean>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
| Field | Required | Default | Description |
|---|---|---|---|
machine_id | Y | Target device/machine identifier in Defender for Endpoint | |
severity | Y | Alert severity: Low, Medium, or High (case insensitive) | |
title | Y | Brief alert title describing the security event | |
alert_description | Y | Detailed alert description with context and findings | |
recommended_action | Y | Suggested remediation steps for security teams | |
category | Y | Alert category (see valid categories in Details section) | |
report_id | Y | Unique identifier for tracking and correlating related alerts | |
tenant_id | N | ${GRAPH_TENANT_ID} | Azure AD tenant ID |
client_id | N | ${GRAPH_CLIENT_ID} | Application (client) ID from Azure AD app registration |
client_secret | N | ${GRAPH_CLIENT_SECRET} | Client secret for authentication |
event_time | N | Current time | Event timestamp in ISO 8601 format (e.g., 2024-01-15T10:30:00Z) |
description | N | Explanatory note | |
if | N | Conditional expression for processor execution | |
disabled | N | false | Disable this processor |
ignore_failure | N | false | Continue pipeline on processor failure |
ignore_missing | N | false | Continue if source field missing |
on_failure | N | Processors to execute on failure | |
on_success | N | Processors to execute on success | |
tag | N | Identifier for this processor instance |
Details
The msdefender_create processor creates custom alerts in Microsoft Defender for Endpoint using the CreateAlertByReference API, enabling external security detection systems to integrate with Microsoft's unified endpoint security platform.
Authentication: Uses OAuth 2.0 client credentials flow with Azure AD. The processor automatically obtains and manages access tokens with caching for performance. Ensure your Azure AD application has the necessary API permissions (Alert.ReadWrite.All or similar) for Defender for Endpoint.
Machine ID: The target device identifier must exist in your Defender for Endpoint environment. You can obtain machine IDs through the Defender portal or via the Machines API. The machine_id field supports template syntax for dynamic values.
Severity Levels: Determines alert priority and visual indicators in Defender portal. Severity values are case insensitive and normalized to the API's required format (Low, Medium, High). Invalid severity values result in processor failure.
Alert Categories: The processor validates category values against Microsoft Defender's supported categories:
General- General security eventsCommandAndControl- C2 communication attemptsCollection- Data collection activitiesCredentialAccess- Credential theft attempts (MITRE ATT&CK T1003, T1110, etc.)DefenseEvasion- Defense evasion techniquesDiscovery- Network/system discovery activitiesExfiltration- Data exfiltration attemptsExploit- Exploitation activitiesExecution- Malicious code executionInitialAccess- Initial access techniquesLateralMovement- Lateral movement activitiesMalware- Malicious software detectionPersistence- Persistence mechanismsPrivilegeEscalation- Privilege escalation attemptsRansomware- Ransomware-related activitiesSuspiciousActivity- Unusual behavior patterns
Report ID: Use this field to correlate related alerts across different events. Multiple alerts with the same report_id help security analysts understand the full attack chain and event relationships.
Automated Investigation: Alerts created through this processor trigger Defender's Automated Investigation and Response (AIR) capabilities, enabling automatic containment and remediation based on configured policies.
Template Support: All string fields support Go template syntax with triple curly braces {{{field_name}}} for event field interpolation, enabling dynamic alert content based on telemetry data.
Token Caching: OAuth access tokens are automatically cached to minimize authentication overhead and improve performance when creating multiple alerts in succession.
Examples
Basic Alert Creation
Creating a high-severity security alert from detected suspicious activity... | |
Alert created in Defender portal with AIR triggered for automatic investigation... |
Malware Detection Alert
Reporting malware detection from external scanner... | |
Malware alert with automatic quarantine investigation initiated... |
Credential Access Detection
Alerting on credential dumping attempts with MITRE ATT&CK mapping... | |
MITRE ATT&CK mapped alert for credential theft investigation... |
Ransomware Detection
Critical ransomware detection requiring immediate action... | |
High-priority alert triggering automatic device isolation... |
Custom Event Time
Reporting historical events with specific timestamps for forensic analysis... | |
Alert with historical timestamp for forensic timeline analysis... |
Template Processing
Using templates to construct dynamic alert content from event fields... | |
Alert with interpolated values from event data for context-rich reporting... |
Error Handling
Continuing pipeline execution even if alert creation fails... | |
Pipeline continues even if Defender API is unavailable... |
Azure AD App Registration
To use the msdefender_create processor, you must register an application in Azure AD with appropriate permissions:
-
Register Application:
- Navigate to Azure Portal > Microsoft Entra ID > App registrations > New registration
- Choose a name and select supported account types
- Register the application
-
Create Client Secret:
- Go to Certificates & secrets > New client secret
- Add description and expiration
- Copy the secret value (shown only once)
-
Assign API Permissions:
- Go to API Permissions > Add permission
- Select "APIs my organization uses" > Search for "WindowsDefenderATP"
- Choose Application permissions > Alert.ReadWrite.All
- Grant admin consent
-
Configure Environment Variables:
export GRAPH_TENANT_ID="your-tenant-id"
export GRAPH_CLIENT_ID="your-client-id"
export GRAPH_CLIENT_SECRET="your-client-secret" -
Obtain Machine IDs:
- Machine IDs can be found in the Defender portal under Devices
- Or retrieved via the Machines API endpoint
For detailed setup instructions, see Microsoft Defender for Endpoint API Documentation.