收集 Google Cloud 计算上下文日志

支持的语言:

本文档介绍了如何使用 Cloud Storage 将 Google Cloud 计算上下文日志导出并注入到 Google Security Operations 中。解析器会从 JSON 格式的日志中提取信息。然后,它会将提取的数据标准化并结构化为 Google SecOps UDM 格式,重点关注虚拟机(如硬件规格、网络配置、安全设置)的详细信息以及与其他实体的关系。

准备工作

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

  • Google SecOps 实例。
  • 计算已在您的 Google Cloud 环境中设置并处于有效状态。
  • 对 Google Cloud 的特许访问权限和适当的权限。

创建 Cloud Storage 存储桶

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

    进入“存储桶”

  3. 点击创建

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

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

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

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

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

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

      1. 选择位置类型
      2. 使用位置类型菜单选择一个位置,用于永久存储存储桶中的对象数据。

      3. 如需设置跨存储桶复制,请展开设置跨存储桶复制部分。

    3. 为数据选择一个存储类别部分中,为存储桶选择默认存储类别,或者选择 Autoclass 对存储桶数据进行自动存储类别管理。

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

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

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

配置 Google Cloud 计算日志导出

  1. 登录 Google Cloud 控制台
  2. 前往日志记录 > 日志路由器
  3. 点击创建接收器
  4. 提供以下配置参数:

    • 接收器名称:输入一个有意义的名称,例如 Compute-Context-Sink
    • 接收器目标位置:选择 Cloud Storage 存储空间,然后输入存储桶的 URI,例如 gs://compute-context-logs
    • 日志过滤条件

      logName="*compute*"
      resource.type="gce_instance"
      
  5. 点击创建

配置 Cloud Storage 权限

  1. 前往 IAM 和管理> IAM
  2. 找到 Cloud Logging 服务账号。
  3. 授予对相应存储桶的 roles/storage.admin

设置 Feed

您可以通过两种不同的入口点在 Google SecOps 平台中设置 Feed:

  • SIEM 设置 > Feed > 添加新 Feed
  • 内容中心 > 内容包 > 开始

如何设置 Google Cloud 计算上下文 Feed

  1. 点击 Google Cloud Compute 平台包。
  2. 找到 GCP Compute Context 日志类型。
  3. 指定以下值:

    • 数据源类型:Google Cloud Storage V2。
    • 存储分区 URI:Cloud Storage 存储桶网址;例如 gs://compute-context-logs
    • 来源删除选项:根据您的偏好设置选择删除选项。

    • 文件存在时间上限:在过去指定天数内修改的文件。默认值为 180 天。

    • Chronicle 服务账号:复制服务账号。您需要此服务账号才能在存储桶中添加权限,以便 Google SecOps 读取或删除存储桶中的数据。

    高级选项

    • Feed 名称:用于标识 Feed 的预填充值。
    • 资源命名空间:与 Feed 关联的命名空间。
    • 提取标签:应用于相应 Feed 中所有事件的标签。
  4. 点击创建 Feed

如需详细了解如何为相应产品系列中的不同日志类型配置多个 Feed,请参阅按产品配置 Feed

UDM 映射表

日志字段 UDM 映射 逻辑
祖先 event.idm.entity.entity.asset.attribute.labels.value 祖先数组中的每个祖先值都会映射到键为 ancestors 的单独标签。
assetType event.idm.entity.entity.asset.category 直接从 assetType 字段映射。
asset_type event.idm.entity.entity.asset.category 直接从 asset_type 字段映射。
name event.idm.entity.entity.resource.name 直接从名称字段映射。
resource.data.cpuPlatform event.idm.entity.entity.asset.hardware.cpu_platform 直接从 resource.data.cpuPlatform 字段映射。
resource.data.creationTimestamp event.idm.entity.entity.asset.attribute.creation_time 从 resource.data.creationTimestamp 字段解析为时间戳格式。
resource.data.id event.idm.entity.entity.asset.product_object_id 直接从 resource.data.id 字段映射。
resource.data.labels.business_function event.idm.entity.entity.asset.attribute.labels.value 直接从 resource.data.labels.business_function 字段映射,并将键设置为 business_function
resource.data.labels.environment event.idm.entity.entity.asset.attribute.labels.value 直接从 resource.data.labels.environment 字段映射,并将键设置为 environment
resource.data.labels.infra_location event.idm.entity.entity.asset.attribute.labels.value 直接映射自 resource.data.labels.infra_location 字段,并将键设置为 infra_location
resource.data.labels.instance_group event.idm.entity.user.group_identifiers 直接从 resource.data.labels.instance_group 字段映射。
resource.data.labels.os event.idm.entity.entity.asset.platform_software.platform_version 直接从 resource.data.labels.os 字段映射。
resource.data.labels.primary_application event.idm.entity.entity.asset.attribute.labels.value 直接从 resource.data.labels.primary_application 字段映射,并将键设置为 primary_application
resource.data.labels.project_code event.idm.entity.entity.asset.attribute.labels.value 直接从 resource.data.labels.project_code 字段映射,并将键设置为 project_code
resource.data.lastStartTimestamp event.idm.entity.entity.asset.last_boot_time 从 resource.data.lastStartTimestamp 字段解析为时间戳格式。
resource.data.machineType event.idm.entity.entity.asset.hardware.model 使用正则表达式从 resource.data.machineType 字段中提取机器类型。
resource.data.name event.idm.entity.entity.asset.hostname 直接从 resource.data.name 字段映射。
resource.data.networkInterfaces.0.accessConfigs.0.natIP event.idm.entity.entity.asset.nat_ip 系统会映射第一个网络接口中的第一个 NAT IP 地址。
resource.data.networkInterfaces.0.network event.idm.entity.entity.asset.attribute.cloud.vpc.name 网络 ID 是使用正则表达式从 resource.data.networkInterfaces.0.network 字段中提取的。
resource.data.networkInterfaces.0.networkIP event.idm.entity.entity.asset.ip 第一个网络接口的 IP 地址已映射。
resource.data.networkInterfaces.1.networkIP event.idm.entity.entity.asset.ip 第二个网络接口的 IP 地址已映射。
resource.data.selfLink event.idm.entity.entity.url 直接从 resource.data.selfLink 字段映射。
resource.data.serviceAccounts.0.email event.idm.entity.relations.entity.user.email_addresses 第一个服务账号的电子邮件地址已映射。
resource.data.status event.idm.entity.entity.asset.deployment_status 如果状态为 RUNNINGPROVISIONINGSTAGINGSTOPPINGSUSPENDINGSUSPENDEDREPAIRINGTERMINATED 之一,则映射到 ACTIVE。否则,映射到 DEPLOYMENT_STATUS_UNSPECIFIED
event.idm.entity.entity.asset.attribute.cloud.availability_zone 可用区是通过合并区域和 zone_suffix 字段来构建的。
event.idm.entity.entity.asset.attribute.cloud.environment 设置为 GOOGLE_CLOUD_PLATFORM
event.idm.entity.entity.asset.attribute.cloud.project.name 项目 ID 是使用正则表达式从名称字段中提取的。
event.idm.entity.entity.asset.attribute.cloud.project.resource_type 设置为 CLOUD_PROJECT
event.idm.entity.entity.asset.attribute.cloud.vpc.resource_type 设置为 VPC_NETWORK
event.idm.entity.entity.resource.resource_type 如果 asset_type 或 assetType 包含 Instance,则设置为 VIRTUAL_MACHINE
event.idm.entity.entity.resource.type 如果 asset_type 或 assetType 包含 Instance,则设置为 VIRTUAL_MACHINE
event.idm.entity.metadata.collected_timestamp 设置为 Logstash 事件时间戳。
event.idm.entity.metadata.entity_type 设置为 ASSET
event.idm.entity.metadata.product_name 设置为 GCP Compute Context
event.idm.entity.metadata.vendor_name 设置为 Google Cloud Platform
event.idm.entity.relations.entity.user.attribute.cloud.environment 设置为 GOOGLE_CLOUD_PLATFORM
event.idm.entity.relations.entity_type 设置为 USER
event.idm.entity.relations.relationship 设置为 ADMINISTERS

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