Collect Datadog logs
Overview
This parser extracts fields from Datadog logs, performs several mutations and Grok matching to structure the data, and maps the extracted fields to the UDM. It handles different log formats within the messagefield, including key-value pairs and JSON objects, and converts specific fields into UDM-compliant labels and additional fields.
Before you begin
Ensure that you have the following prerequisites:
- Google SecOps instance.
- Privileged access to Google Cloud IAM.
- Privileged access to Cloud Storage.
-  logs_write_archiveuser access to Datadog.
Option 1: Datadog log sharing through Cloud Storage configuration
Configure Datadog integration with Google Cloud Platform
- Set up an integration for Google Cloud Platform in Datadog . For more information, see the Datadog Google Cloud integration setup .
Create a Google Cloud Storage Bucket
- Sign in to the Google Cloud console.
-  Go to the Cloud Storage Bucketspage. 
-  Click Create. 
-  On the Create a bucketpage, enter your bucket information. After each of the following steps, click Continueto proceed to the next step: -  In the Get startedsection, do the following: - Enter a unique name that meets the bucket name requirements (for example, datadog-data).
-  To enable hierarchical namespace, click the expander arrow to expand the Optimize for file oriented and data-intensive workloadssection, and then select Enable Hierarchical namespace on this bucket. 
-  To add a bucket label, click the expander arrow to expand the Labelssection. 
-  Click Add label, and specify a key and a value for your label. 
 
-  In the Choose where to store your datasection, do the following: - Select a Location type.
- Use the location type drop-down to select a Locationwhere object data within your bucket will be permanently stored. - If you select the dual-regionlocation type, you can also choose to enable turbo replicationby using the relevant checkbox.
 
- To set up cross-bucket replication, expand the Set up cross-bucket replicationsection.
 
-  In the Choose a storage class for your datasection, either select a default storage classfor the bucket, or select Autoclassfor automatic storage class management of your bucket's data. 
-  In the Choose how to control access to objectssection, select notto enforce public access prevention, and select an access control modelfor your bucket's objects. 
-  In the Choose how to protect object datasection, do the following: - Select any of the options under Data protectionthat you want to set for your bucket.
- To choose how your object data will be encrypted, click the expander arrow labeled Data encryption, and select a Data encryption method.
 
 
-  
-  Click Create. 
Create a Google Cloud Service Account
- Go to IAM & Admin > Service Accounts.
- Create a new service account.
- Give it a descriptive name (For example, datadog-user).
- Grant the service account with Storage Object Adminrole on the Cloud Storage bucket you created in the previous step.
- Create an SSH key for the service account.
- Download a JSON key file for the service account. Keep this file secure.
Configure Datadog to send logs to Cloud Storage
- Sign in to Datadog using a privileged account.
- Go to Logs > Log Forwarding.
- Click + Create New Archive.
- Select Google Cloud Storage.
- Input the required parameters and click Save.
Option 2: Datadog log sharing through Webhook configuration
Set up feeds
To configure a feed, follow these steps:
- Go to SIEM Settings > Feeds.
- Click Add New Feed.
- On the next page, click Configure a single feed.
- In the Feed namefield, enter a name for the feed (for example, Datadog Logs).
- Select Webhookas the Source type.
- Select Datadogas the Log type.
- Click Next.
- Optional: Specify values for the following input parameters: -  Split delimiter: the delimiter that is used to separate log lines, such as \n.
 
-  Split delimiter: the delimiter that is used to separate log lines, such as 
- Click Next.
- Review the feed configuration in the Finalizescreen, and then click Submit.
- Click Generate Secret Keyto generate a secret key to authenticate this feed.
- Copy and store the secret key. You cannot view this secret key again. If needed, you can regenerate a new secret key, but this action makes the previous secret key obsolete.
- From the Detailstab, copy the feed endpoint URL from the Endpoint Informationfield. You need to specify this endpoint URL in your client application.
- Click Done.
Create an API key for the webhook feed
-  Go to Google Cloud console > Credentials. 
-  Click Create credentials, and then select API key. 
-  Restrict the API key access to the Chronicle API. 
Specify the endpoint URL
- In your client application, specify the HTTPS endpoint URL provided in the webhook feed.
-  Enable authentication by specifying the API key and secret key as part of the custom header in the following format: X-goog-api-key = API_KEY X-Webhook-Access-Key = SECRETRecommendation: Specify the API key as a header instead of specifying it in the URL. 
-  If your webhook client doesn't support custom headers, you can specify the API key and secret key using query parameters in the following format: ENDPOINT_URL ?key= API_KEY &secret= SECRETReplace the following: -  ENDPOINT_URL: the feed endpoint URL.
-  API_KEY: the API key to authenticate to Google SecOps.
-  SECRET: the secret key that you generated to authenticate the feed.
 
-  
Configure Datadog to send logs to webhook
- Sign in to Datadog using a privileged account.
- Go to Logs > Log Forwarding.
- Select Custom Destinations.
- Click + Create a New Destination.
- Specify values for the following input parameters: - Choose a destination type: Select HTTP.
- Name the destination: Provide a descriptive name for the webhook (for example, Google SecOps Webhook).
- Configure the destination: Enter the ENDPOINT_URL, followed by the API_KEYand SECRET.
-  Configure authentication settings: Add a general header like the following, this won't malform the HTTP request and allow Datadog to complete webhook creation. - Header name: Accept.
- Header value: application/json.
 
- Header name: 
- Click Save.
 
Reference Links
UDM Mapping Table
| Log Field | UDM Mapping | Logic | 
|---|---|---|
| _id | read_only_udm.metadata.product_log_id | Directly mapped from the _idfield. | 
| alert | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the alertfield and added as a label within thesecurity_resultobject. | 
| attributes.@timestamp | read_only_udm.metadata.event_timestamp | The event timestamp is extracted from the attributes.@timestampfield and converted to seconds and nanoseconds. | 
| attributes.@version | read_only_udm.metadata.product_version | Directly mapped from the attributes.@versionfield. | 
| attributes.level_value | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the attributes.level_valuefield and added as a label within thesecurity_resultobject. | 
| attributes.logger_name | read_only_udm.principal.application | Directly mapped from the attributes.logger_namefield. | 
| attributes._trace.baggage._sli_service | read_only_udm.additional.fields | Directly mapped from the attributes._trace.baggage._sli_servicefield and added as an additional field. | 
| attributes._trace.baggage.device_id | read_only_udm.principal.asset.asset_id | Directly mapped from the attributes._trace.baggage.device_idfield, prefixed with "Device Id:". | 
| attributes._trace.origin.operation | read_only_udm.metadata.product_event_type | Directly mapped from the attributes._trace.origin.operationfield. | 
| caller | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the callerfield and added as a label within thesecurity_resultobject. | 
| component | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the componentfield and added as a label within thesecurity_resultobject. | 
| context.AlertName | read_only_udm.security_result.threat_name | Directly mapped from the context.AlertNamefield. | 
| context.BusArch | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the context.BusArchfield and added as a label within thesecurity_resultobject. | 
| context.CANDBVersion | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the context.CANDBVersionfield and added as a label within thesecurity_resultobject. | 
| context.esn | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the context.esnfield and added as a label within thesecurity_resultobject. | 
| context.ftcpVersion | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the context.ftcpVersionfield and added as a label within thesecurity_resultobject. | 
| context.ingestMessageId | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the context.ingestMessageIdfield and added as a label within thesecurity_resultobject. | 
| context.redactedVin | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the context.redactedVinfield and added as a label within thesecurity_resultobject. | 
| context.vehicleId | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the context.vehicleIdfield and added as a label within thesecurity_resultobject. | 
| date | read_only_udm.metadata.collected_timestamp | The collected timestamp is extracted from the datefield (renamed todate1in the parser) and converted to seconds and nanoseconds. | 
| host | read_only_udm.principal.hostname | Directly mapped from the hostfield. | 
| message | read_only_udm.security_result.about.resource.attribute.labels | The messagefield is parsed, and parts of it are used to populate the summaryand json_datafields. The remaining part is treated as key-value pairs and added as labels within the security_resultobject. | 
| msg | read_only_udm.security_result.about.resource.attribute.labels | Extracted from the msgfield and added as a label within thesecurity_resultobject. | 
| service | read_only_udm.metadata.product_name | Directly mapped from the servicefield. | 
| status | read_only_udm.security_result.severity | The severity is determined based on the statusfield. "INFO", "DEBUG", "debug", and "info" map to "LOW", "WARN" maps to "MEDIUM", and other values are not explicitly mapped in the provided code snippet. | 
| tags | read_only_udm.additional.fields | Each tag in the tagsarray is parsed into key-value pairs and added as additional fields. | 
|   
N/A | read_only_udm.metadata.event_type | Set to "STATUS_UPDATE" if the hostfield is present, and "GENERIC_EVENT" otherwise. | 
Need more help? Get answers from Community members and Google SecOps professionals.

