收集 Datadog 日志

支持的平台:

概览

此解析器从 Datadog 日志中提取字段,执行多项突变和 Grok 匹配来构建数据,并将提取的字段映射到 UDM。它会处理 message 字段中的不同日志格式(包括键值对和 JSON 对象),并将特定字段转换为符合 UDM 标准的标签和其他字段。

准备工作

确保您满足以下前提条件:

  • Google SecOps 实例。
  • 对 Google Cloud IAM 的特权访问权限。
  • 对 Cloud Storage 的特权访问权限。
  • logs_write_archive 用户对 Datadog 的访问权限。

方法 1:通过 Cloud Storage 配置实现 Datadog 日志共享

配置 Datadog 与 Google Cloud 平台的集成

创建 Google Cloud 存储分区

  1. 登录 Google Cloud 控制台。
  2. 前往 Cloud Storage 存储分区页面。

    进入“存储桶”

  3. 点击创建

  4. 创建存储桶页面上,输入您的存储桶信息。完成以下每一步后,点击继续以继续执行后续步骤:

    1. 开始使用部分中,执行以下操作:

      1. 输入符合存储桶名称要求的唯一名称(例如 datadog-data)。
      2. 如需启用分层命名空间,请点击展开箭头以展开优化文件导向型和数据密集型工作负载部分,然后选择在此存储桶上启用分层命名空间

      3. 如需添加存储桶标签,请点击展开箭头以展开标签部分。

      4. 点击添加标签,然后为标签指定键和值。

    2. 选择数据存储位置部分中,执行以下操作:

      1. 选择位置类型
      2. 使用位置类型下拉菜单选择一个位置,用于永久存储存储桶中的对象数据。
        • 如果您选择双区域位置类型,还可以通过勾选相关复选框来启用增强型复制
      3. 如需设置跨存储桶复制,请展开设置跨存储桶复制部分。
    3. 为数据选择一个存储类别部分中,为存储桶选择默认存储类别,或者选择 Autoclass 对存储桶数据进行自动存储类别管理。

    4. 选择如何控制对对象的访问权限部分中,选择强制执行禁止公开访问,然后为存储桶对象选择访问权限控制模型

    5. 选择如何保护对象数据部分中,执行以下操作:

      1. 数据保护下,选择您要为存储桶设置的任何选项。
      2. 如需选择对象数据的加密方式,请点击标有数据加密的展开箭头,然后选择数据加密方法
  5. 点击创建

创建 Google Cloud 服务账号

  1. 前往 IAM 和管理 > 服务账号
  2. 创建新的服务账号。
  3. 为其指定一个描述性名称(例如,datadog-user)。
  4. 向服务账号授予您在上一步中创建的 Cloud Storage 存储桶的 Storage Object Admin 角色。
  5. 为服务账号创建 SSH 密钥
  6. 下载服务账号的 JSON 密钥文件。请确保此文件的安全。

配置 Datadog 以将日志发送到 Cloud Storage

  1. 使用特权账号登录 Datadog。
  2. 依次前往日志 > 日志转发
  3. 点击 + 创建新归档文件
  4. 选择 Google Cloud Storage
  5. 输入必需参数,然后点击保存

方法 2:通过 Webhook 配置共享 Datadog 日志

设置 Feed

如需配置 Feed,请按以下步骤操作:

  1. 依次前往 SIEM 设置 > Feed
  2. 点击添加新 Feed
  3. 在下一页上,点击配置单个 Feed
  4. Feed 名称字段中,输入 Feed 的名称(例如 Datadog 日志)。
  5. 选择 Webhook 作为来源类型
  6. 选择 Datadog 作为日志类型
  7. 点击下一步
  8. 可选:为以下输入参数指定值:
    • 拆分分隔符:用于分隔日志行的分隔符,例如 \n
  9. 点击下一步
  10. 最终确定界面中检查 Feed 配置,然后点击提交
  11. 点击生成密钥,生成用于对此 Feed 进行身份验证的密钥。
  12. 复制并存储密钥。您将无法再次查看此密钥。如有需要,您可以重新生成新的 Secret 密钥,但此操作会使之前的 Secret 密钥失效。
  13. 详情标签页中,从端点信息字段复制 Feed 端点网址。您需要在客户端应用中指定此端点网址。
  14. 点击完成

为 Webhook Feed 创建 API 密钥

  1. 依次前往 Google Cloud 控制台 > 凭据

    转到“凭据”页面

  2. 点击创建凭据,然后选择 API 密钥

  3. 将 API 密钥访问权限限制为 Chronicle API

指定端点网址

  1. 在客户端应用中,指定 webhook Feed 中提供的 HTTPS 端点网址。
  2. 通过在自定义标头中指定 API 密钥和密钥来启用身份验证,格式如下:

    X-goog-api-key = API_KEY
    X-Webhook-Access-Key = SECRET
    

    建议:将 API 密钥指定为标头,而不是在网址中指定。

  3. 如果您的 Webhook 客户端不支持自定义标头,您可以使用以下格式的查询参数指定 API 密钥和密钥:

    ENDPOINT_URL?key=API_KEY&secret=SECRET
    

    替换以下内容:

    • ENDPOINT_URL:Feed 端点网址。
    • API_KEY:用于向 Google SecOps 进行身份验证的 API 密钥。
    • SECRET:您生成的用于验证 Feed 的密钥。

配置 Datadog 以将日志发送到网络钩子

  1. 使用特权账号登录 Datadog。
  2. 依次前往日志 > 日志转发
  3. 选择自定义目的地
  4. 点击 + 创建新目标
  5. 为以下输入参数指定值:
    1. 选择目标类型:选择 HTTP
    2. 为目的地命名:为 webhook 提供一个描述性名称(例如 Google SecOps Webhook)。
    3. 配置目的地:输入 ENDPOINT_网址,然后输入 API_KEYSECRET
    4. 配置身份验证设置:添加如下所示的常规标头,这样就不会使 HTTP 请求格式有误,并且允许 Datadog 完成网络钩子创建。
      • 标头名称:Accept
      • 标头值:application/json
    5. 点击保存

支持的 Datadog 示例日志

  • 此日志示例包含嵌入在 data 字段中的原始应用日志数据(以 JSON 字符串形式):

    {
    "batch": {
        "id": "DUMMY_BATCH_ID",
        "source": {
        "customer_id": "DUMMY_CUSTOMER_ID",
        "collector_id": "DUMMY_COLLECTOR_ID"
        },
        "log_type": "DDOG",
        "entries": {
        "data": "{\"date\":\"2023-06-20T13:41:42.359Z\",\"service\":\"ftcp-converter\",\"host\":\"DUMMY_HOST-001\",\"attributes\":{\"_trace\":{\"baggage\":{\"device_id\":\"DUMMY-DEVICE-ID\",\"vehicle_id\":\"DUMMY-VEHICLE-ID\",\"_sli_service\":\"ftcp-converter/DUMMY_ENCODED_SLI\"},\"origin\":{\"service\":\"ftcp-converter\",\"operation\":\"ProcessingService.processAndPublish\"},\"id\":\"DUMMY_TRACE_ID\"},\"@timestamp\":\"2023-06-20T13:41:42.359Z\",\"level\":\"WARN\",\"thread_name\":\"Processing-327\",\"level_value\":30000,\"@version\":\"1\",\"logger_name\":\"com.autonomic.ftcp.conversion.FTCPConverter\"},\"_id\":\"DUMMY_EVENT_ID\",\"source\":\"ftcp-converter\",\"message\":\"Timestamp Exception thrown: TOO_FAR_IN_PAST errorMessage: No timestamp available, error status:TOO_FAR_IN_PAST { \\\"context\\\":{\\\"BusArch\\\":\\\"3\\\",\\\"esn\\\":\\\"FP001CE3\\\",\\\"CANDBVersion\\\":\\\"B_v19.04A\\\",\\\"ftcpVersion\\\":\\\"5.0.9\\\",\\\"AlertName\\\":\\\"MotiveModeEndAlert\\\",\\\"ingestMessageId\\\":\\\"DUMMY-INGEST-ID\\\",\\\"vehicleId\\\":\\\"DUMMY-VEHICLE-ID\\\",\\\"redactedVin\\\":\\\"len=17\\\",\\\"deviceId\\\":\\\"DUMMY-DEVICE-ID\\\",\\\"timestamp\\\":null} }\",\"status\":\"warn\",\"tags\":[\"kube_namespace:alfa\",\"pod_label_autonomic.ai/tracing:true\",\"kube_app_name:ftcp-converter\", /* ... other tags ... */, \"docker_image:DUMMY_ECR_HOST/au/ftcp-converter:DUMMY_TAG\",\"aws-instance-type:m5.8xlarge\",\"cluster_name:staging\",\"env:staging\",\"kube_cluster_name:staging\",\"kube_role:node\",\"autonomic_ai_team:telemetry-data\"]}",
        "collection_time": {
            "seconds": 1689231423,
            "nanos": 972102587
        }
        }
    }
    }
    
  • 此示例详细说明了 API 请求,并包含网络和威胁情报元数据:

    [
    {
        "date": "2025-02-13T08:35:41.000Z",
        "attributes": {
        "auth_method": "SESSION",
        "evt": {
            "actor": {
            "type": "USER"
            },
            "name": "Request"
        },
        "org": {
            "uuid": "DUMMY-ORG-UUID"
        },
        "usr": {
            "id": "dummy.user@example.com",
            "uuid": "DUMMY-USER-UUID",
            "email": "dummy.user@example.com"
        },
        "action": "accessed",
        "http": {
            "status_code": 202,
            "url_details": {
            "path": "/api/ui/frontend_telemetry/metrics",
            "host": "us1.DUMMY-HOST.dog"
            },
            "method": "POST",
            "useragent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36"
        },
        "threat_intel": {
            "indicators_matched": [
            "IP"
            ],
            "results": [
            {
                "indicator": "0.0.0.0",
                "additional_data": {
                "tunnels": [
                    {
                    "anonymous": true,
                    "type": "VPN"
                    }
                ],
                "as": {
                    "number": 16509,
                    "organization": "DUMMY-AS-ORGANIZATION"
                },
                "risks": [
                    "TUNNEL"
                ],
                "infrastructure": "DATACENTER",
                "organization": "DUMMY-ORG-GMBH",
                "client": {},
                "location": {
                    "country": "DE",
                    "city": "Frankfurt am Main",
                    "state": "Hesse"
                },
                "services": [
                    "IPSEC"
                ]
                },
                "source": {
                "name": "spur",
                "type": "managed",
                "url": "https://DUMMY-URL.us"
                },
                "type": "IP",
                "category": "hosting_proxy",
                "intention": "suspicious"
            }
            ]
        },
        "network": {
            "client": {
            "geoip": {
                "continent": {
                "code": "EU",
                "name": "Europe"
                },
                "country": {
                "name": "Germany",
                "iso_code": "DE"
                },
                "subdivision": {
                "name": "Hesse",
                "iso_code": "DE-HE"
                },
                "as": {
                "number": "AS16509",
                "route": "DUMMY_CIDR",
                "domain": "DUMMY-DOMAIN.com",
                "name": "DUMMY-AS-NAME, Inc.",
                "type": "hosting"
                },
                "city": {
                "name": "Frankfurt am Main"
                },
                "timezone": "Europe/Berlin",
                "ipAddress": " ",
                "location": {
                "latitude": 50.11552,
                "longitude": 8.68417
                }
            },
            "ip": " "
            }
        },
        "status": "info",
        "timestamp": "2025-02-13T08:35:41Z",
        "emitted_source": "edge"
        },
        "_id": "AZT-cxO1AAA63poCZjbsDgAA",
        "source": "audit",
        "message": "POST request made to /api/ui/frontend_telemetry/metrics by dummy.user@example.com with response 202",
        "status": "info",
        "tags": [
        "source:audit"
        ]
    }
    ]
    
  • 此示例详细说明了用户对资源(日志转发查询)所做的修改:

    {
    "date": "2025-08-12T10:33:55.000Z",
    "attributes": {
        "evt": {
        "actor": {
            "type": "USER"
        },
        "name": "Log Management"
        },
        "metadata": {
        "dd": {
            "request_id": "DUMMY-REQUEST-ID"
        }
        },
        "auth_method": "SESSION",
        "org": {
        "name": "DUMMY_ORG_NAME",
        "uuid": "DUMMY-ORG-UUID"
        },
        "usr": {
        "created": "2025-05-13T13:33:27Z",
        "name": "John Doe",
        "id": "user.name@example.com",
        "uuid": "DUMMY-USER-UUID",
        "email": "user.name@example.com"
        },
        "action": "modified",
        "http": {
        "status_code": 200,
        "url_details": {
            "path": "/api/ui/event-platform/logs/custom-destinations/DUMMY-DESTINATION-ID"
        },
        "method": "PUT",
        "level": "info",
        "useragent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0"
        },
        "asset": {
        "modified_field": "query",
        "name": "Google Secops Logs",
        "id": "DUMMY-DESTINATION-ID",
        "type": "log_forwarding",
        "prev_value": {
            "data": {
            "attributes": {
                "query": "host:(DUMMY-HOST-PRD-01 OR DUMMY-HOST-PRD-02 OR DUMMY-HOST-PRD-03 OR DUMMY-HOST-STG-01 OR DUMMY-HOST-STG-02 OR DUMMY-HOST-STG-03 OR DUMMY-HOST-EMEA-01 OR DUMMY-HOST-STG-04 OR DUMMY-HOST-PRD-04) status:(notice OR warn OR error)"
            }
            }
        },
        "new_value": {
            "data": {
            "attributes": {
                "query": "service:(sqb-connector-services OR nginx-ingress-controller) status:(notice OR warn OR error)"
            }
            }
        }
        },
        "network": {
        "client": {
            "geoip": {
            "continent": {
                "code": "EU",
                "name": "Europe"
            },
            "country": {
                "name": "United Kingdom",
                "iso_code": "GB"
            },
            "subdivision": {
                "name": "DUMMY_CITY",
                "iso_code": "DUMMY_CODE"
            },
            "as": {
                "number": "AS25180",
                "route": "DUMMY-CIDR-RANGE",
                "domain": "DUMMY-DOMAIN.com",
                "name": "DUMMY-ISP-NAME",
                "type": "hosting"
            },
            "city": {
                "name": "London"
            },
            "timezone": "Europe/London",
            "ipAddress": " ",
            "location": {
                "latitude": 51.50853,
                "longitude": -0.12574
            }
            },
            "ip": " "
        }
        },
        "status": "info",
        "timestamp": "2025-08-12T10:33:55Z"
    },
    "_id": "AZid2AB0AAAxoDbhbVS-EAAA",
    "source": "audit",
    "message": "user.name@example.com successfully changed query from \"host:(DUMMY-HOST-PRD-01 OR DUMMY-HOST-PRD-02 OR DUMMY-HOST-PRD-03 OR DUMMY-HOST-STG-01 OR DUMMY-HOST-STG-02 OR DUMMY-HOST-STG-03 OR DUMMY-HOST-EMEA-01 OR DUMMY-HOST-STG-04 OR DUMMY-HOST-PRD-04) status:(notice OR warn OR error)\" to \"service:(sqb-connector-services OR nginx-ingress-controller) status:(notice OR warn OR error)\" for custom destination \"Google Secops Logs\" (DUMMY-DESTINATION-ID)",
    "status": "info"
    }
    

UDM 映射表

日志字段 UDM 映射 逻辑
_id read_only_udm.metadata.product_log_id 直接从 _id 字段映射。
alert read_only_udm.security_result.about.resource.attribute.labels alert 字段中提取,并作为标签添加到 security_result 对象中。
attributes.@timestamp read_only_udm.metadata.event_timestamp 事件时间戳从 attributes.@timestamp 字段中提取,并转换为秒和纳秒。
attributes.@version read_only_udm.metadata.product_version 直接从 attributes.@version 字段映射。
attributes.level_value read_only_udm.security_result.about.resource.attribute.labels attributes.level_value 字段中提取,并作为标签添加到 security_result 对象中。
attributes.logger_name read_only_udm.principal.application 直接从 attributes.logger_name 字段映射。
attributes._trace.baggage._sli_service read_only_udm.additional.fields 直接从 attributes._trace.baggage._sli_service 字段映射并添加为附加字段。
attributes._trace.baggage.device_id read_only_udm.principal.asset.asset_id 直接从 attributes._trace.baggage.device_id 字段映射,并带有“设备 ID:”前缀。
attributes._trace.origin.operation read_only_udm.metadata.product_event_type 直接从 attributes._trace.origin.operation 字段映射。
caller read_only_udm.security_result.about.resource.attribute.labels caller 字段中提取,并作为 security_result 对象中的标签添加。
component read_only_udm.security_result.about.resource.attribute.labels component 字段中提取,并作为 security_result 对象中的标签添加。
context.AlertName read_only_udm.security_result.threat_name 直接从 context.AlertName 字段映射。
context.BusArch read_only_udm.security_result.about.resource.attribute.labels context.BusArch 字段中提取,并作为 security_result 对象中的标签添加。
context.CANDBVersion read_only_udm.security_result.about.resource.attribute.labels context.CANDBVersion 字段中提取,并作为 security_result 对象中的标签添加。
context.esn read_only_udm.security_result.about.resource.attribute.labels context.esn 字段中提取,并作为 security_result 对象中的标签添加。
context.ftcpVersion read_only_udm.security_result.about.resource.attribute.labels context.ftcpVersion 字段中提取,并作为 security_result 对象中的标签添加。
context.ingestMessageId read_only_udm.security_result.about.resource.attribute.labels context.ingestMessageId 字段中提取,并作为 security_result 对象中的标签添加。
context.redactedVin read_only_udm.security_result.about.resource.attribute.labels context.redactedVin 字段中提取,并作为 security_result 对象中的标签添加。
context.vehicleId read_only_udm.security_result.about.resource.attribute.labels context.vehicleId 字段中提取,并作为 security_result 对象中的标签添加。
date read_only_udm.metadata.collected_timestamp 收集的时间戳是从 date 字段(在解析器中重命名为 date1)中提取的,并转换为秒和纳秒。
host read_only_udm.principal.hostname 直接从 host 字段映射。
message read_only_udm.security_result.about.resource.attribute.labels 系统会解析 message 字段,并使用其中的部分内容来填充 summaryjson_data 字段。剩余部分将作为键值对处理,并作为标签添加到 security_result 对象中。
msg read_only_udm.security_result.about.resource.attribute.labels msg 字段中提取,并作为 security_result 对象中的标签添加。
service read_only_udm.metadata.product_name 直接从 service 字段映射。
status read_only_udm.security_result.severity 严重程度取决于 status 字段。“INFO”“DEBUG”“debug”和“info”映射到“LOW”,“WARN”映射到“MEDIUM”,而其他值在提供的代码段中未明确映射。
tags read_only_udm.additional.fields tags 数组中的每个标记都会被解析为键值对,并添加为其他字段。
不适用 read_only_udm.metadata.event_type 如果存在 host 字段,则设置为“STATUS_UPDATE”,否则设置为“GENERIC_EVENT”。

需要更多帮助?获得社区成员和 Google SecOps 专业人士的解答。