收集 Elastic Auditbeat 日志

支持的平台:

本文档介绍了如何使用 Amazon S3 将 Elastic Auditbeat 日志注入到 Google Security Operations。解析器从 JSON 日志中提取字段,将其标准化为统一数据模型 (UDM),并使用主机信息、网络详细信息和安全结果分类等其他上下文信息来丰富数据。它通过将 event1.action 和其他字段映射到特定的 UDM 元数据事件类型来处理各种事件类型,并在可能的情况下默认使用 GENERIC_EVENT 或更具体的类别。

准备工作

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

  • Google SecOps 实例。
  • Elastic Auditbeat 服务器的特权访问权限。
  • Logstash 服务器的特权访问权限。
  • AWS(S3、Identity and Access Management [IAM])的特权访问权限。

获取 Elastic Auditbeat 前提条件

  1. 确保服务器上已安装并配置 Elastic Auditbeat
  2. 在专用服务器上或与 Auditbeat 一起安装 Logstash
  3. 记下 Auditbeat 配置文件的位置(通常为 /etc/auditbeat/auditbeat.yml)。

为 Google SecOps 配置 AWS S3 存储桶和 IAM

  1. 按照以下用户指南创建 Amazon S3 存储桶创建存储桶
  2. 保存存储桶名称区域以供日后参考(例如 elastic-auditbeat-logs)。
  3. 按照以下用户指南创建用户创建 IAM 用户
  4. 选择创建的用户
  5. 选择安全凭据标签页。
  6. 访问密钥部分中,点击创建访问密钥
  7. 选择第三方服务作为使用情形
  8. 点击下一步
  9. 可选:添加说明标记。
  10. 点击创建访问密钥
  11. 点击下载 .CSV 文件,保存访问密钥秘密访问密钥,以供日后参考。
  12. 点击完成
  13. 选择权限标签页。
  14. 权限政策部分中,点击添加权限
  15. 选择添加权限
  16. 选择直接附加政策
  17. 搜索 AmazonS3FullAccess 政策。
  18. 选择相应政策。
  19. 点击下一步
  20. 点击添加权限

配置 Auditbeat 以发送到 Logstash

  1. 修改 Auditbeat 配置文件 /etc/auditbeat/auditbeat.yml
  2. 注释掉所有现有的输出配置(Elasticsearch 等)。
  3. 添加 Logstash 输出配置:

    # ==================== Outputs ====================
    output.logstash:
      hosts: ["localhost:5044"]
      # If Logstash is on a different server, use its IP/hostname
      # hosts: ["logstash-server:5044"]
    
      # Optional: Enable load balancing if using multiple Logstash instances
      loadbalance: true
    
      # Optional: Configure bulk settings (default is 2048)
      bulk_max_size: 2048
    
      # Optional: Configure SSL if needed
      # ssl.enabled: true
      # ssl.certificate_authorities: ["/path/to/ca.crt"]
    
  4. 重启 Auditbeat 以应用更改:

    sudo systemctl restart auditbeat
    

配置 Logstash 流水线

  1. 创建新的 Logstash 流水线配置文件 /etc/logstash/conf.d/auditbeat-to-s3.conf

    input {
      beats {
        port => 5044
        # Optional: Configure SSL
        # ssl => true
        # ssl_certificate => "/path/to/server.crt"
        # ssl_key => "/path/to/server.key"
      }
    }
    
    filter {
      # Add any necessary transformations here
      # The data should remain in raw JSON format for Chronicle parsing
    
      # Optional: Add metadata for debugging
      mutate {
        add_field => { "[@metadata][pipeline]" => "auditbeat-to-s3" }
      }
    }
    
    output {
      s3 {
        # AWS credentials
        access_key_id => "YOUR_AWS_ACCESS_KEY_ID"
        secret_access_key => "YOUR_AWS_SECRET_ACCESS_KEY"
    
        # S3 bucket configuration
        region => "us-east-1"  # Replace with your bucket region
        bucket => "elastic-auditbeat-logs"  # Replace with your bucket name
    
        # Organize logs by date using Logstash timestamp interpolation
        prefix => "auditbeat/%{+YYYY}/%{+MM}/%{+dd}/"
    
        # File rotation settings
        size_file => 10485760  # 10MB files
        time_file => 5  # Rotate every 5 minutes
    
        # Compression for cost optimization
        encoding => "gzip"
    
        # Output format - keep as JSON for Chronicle
        codec => "json_lines"
    
        # Optional: Server-side encryption
        # server_side_encryption => true
        # server_side_encryption_algorithm => "AES256"
      }
    
      # Optional: Keep a local copy for debugging
      # stdout { 
      #   codec => rubydebug 
      # }
    }
    
    • YOUR_AWS_ACCESS_KEY_IDYOUR_AWS_SECRET_ACCESS_KEY 替换为您的实际 AWS 凭据。
    • 更新 regionbucket 值,以与您的 S3 配置相匹配。
    • 启动或重启 Logstash:
    sudo systemctl restart logstash
    

(可选)为 Google SecOps 创建只读 IAM 用户和密钥

  1. 依次前往 AWS 控制台 > IAM > 用户
  2. 点击 Add users(添加用户)。
  3. 提供以下配置详细信息:
    • 用户:输入 secops-reader
    • 访问类型:选择访问密钥 - 以程序化方式访问
  4. 点击创建用户
  5. 附加最低限度的读取政策(自定义):依次选择用户 > secops-reader > 权限 > 添加权限 > 直接附加政策 > 创建政策
  6. JSON:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": ["s3:GetObject"],
          "Resource": "arn:aws:s3:::elastic-auditbeat-logs/*"
        },
        {
          "Effect": "Allow",
          "Action": ["s3:ListBucket"],
          "Resource": "arn:aws:s3:::elastic-auditbeat-logs"
        }
      ]
    }
    
  7. 名称 = secops-reader-policy

  8. 依次点击创建政策 > 搜索/选择 > 下一步 > 添加权限

  9. secops-reader 创建访问密钥:安全凭据 > 访问密钥

  10. 点击创建访问密钥

  11. 下载 .CSV。(您需要将这些值粘贴到 Feed 中)。

在 Google SecOps 中配置 Feed 以注入 Elastic Auditbeat 日志

  1. 依次前往 SIEM 设置> Feed
  2. 点击 + 添加新 Feed
  3. Feed 名称字段中,输入 Feed 的名称(例如 Elastic Auditbeat Logs)。
  4. 选择 Amazon S3 V2 作为来源类型
  5. 选择 Elastic Audit Beats 作为日志类型
  6. 点击下一步
  7. 为以下输入参数指定值:
    • S3 URIs3://elastic-auditbeat-logs/auditbeat/
    • 来源删除选项:根据您的偏好选择删除选项。
    • 文件存在时间上限:包含在过去指定天数内修改的文件。默认值为 180 天。
    • 访问密钥 ID:有权访问 S3 存储桶的用户访问密钥。
    • 私有访问密钥:具有 S3 存储桶访问权限的用户私有密钥。
    • 资产命名空间资产命名空间
    • 注入标签:应用于此 Feed 中事件的标签。
  8. 点击下一步
  9. 最终确定界面中查看新的 Feed 配置,然后点击提交

UDM 映射表

日志字段 UDM 映射 逻辑
@timestamp metadata.event_timestamp 系统会从 @timestamp 字段解析事件时间戳。
agent.id observer.asset_id 以“agent_id: ”为前缀。
agent.type observer.application 观察者应用设置为代理类型。
agent.version observer.platform_version 观测器平台版本设置为代理版本。
client.bytes principal.labels 以键“Bytes”的形式添加为标签。已转换为字符串。
client.ip principal.ip 主账号 IP 设置为客户端 IP。
client.packets principal.labels 添加为键为“数据包”的标签。已转换为字符串。
client.port principal.port 主端口设置为客户端端口。已转换为整数。
cloud.availability_zone principal.cloud.availability_zone 主云可用区设置为云可用区。
cloud.instance.id principal.resource.id 主账号资源 ID 设置为云实例 ID。
cloud.machine.type principal.resource.resource_subtype 将主资源子类型设置为云机器类型。
cloud.region principal.cloud.availability_zone 如果存在云区域,则会替换可用区。
destination.bytes target.labels 以键“Bytes”的形式添加为标签。已转换为字符串。
destination.ip target.ip 目标 IP 设置为目标 IP。
destination.packets target.labels 添加为键为“数据包”的标签。已转换为字符串。
destination.port target.port 目标端口设置为目标端口。已转换为整数。
ecs.version metadata.product_version 如果存在,则替换 jsonPayload.@metadata.version 中的值。
event1.category security_result.category_details 所有值都会添加到 category_details 中。
event1.duration network.session_duration.seconds 已转换为整数。
event1.id metadata.product_log_id 元数据商品日志 ID 设置为事件 ID。
event1.outcome extensions.auth.auth_details 身份验证详细信息会设置为事件结果。
file.extension target.file.mime_type 目标文件 MIME 类型设置为文件扩展名。
file.hash.sha1 target.file.sha1 目标文件 SHA-1 设置为文件 SHA-1 哈希值。
file.path target.file.full_path 目标文件的完整路径设置为 path。
file.size target.file.size 转换为 uinteger。
group.id principal.group.product_object_id 主群组商品对象 ID 设置为群组 ID。
group.name principal.group.group_display_name 主群组显示名设置为群组名称。
host.architecture principal.asset.hardware.cpu_platform 存储在临时变量 hardware.cpu_platform 中,然后合并到 principal.asset.hardware 中。
host.hostname principal.hostname 将主账号主机名设置为主机主机名。
host.id principal.asset.asset_id 以“Host Id: ”为前缀。
host.ip principal.asset.ip 所有值都会添加到主要资产 IP 中。
host.mac principal.mac 短划线替换为英文冒号。
host.name principal.hostnameobserver.hostname 如果存在,则替换 host.hostname 中的值。
host.os.kernel principal.platform_patch_level 主平台补丁级别设置为宿主操作系统内核。
host.os.version principal.platform_version 主平台版本设置为宿主操作系统版本。存储在临时变量 host_os_version 中。
httpRequest.remoteIp target.ip 如果存在此参数,且未设置其他目标 IP,则使用此值。
httpRequest.requestMethod network.http.method 网络 HTTP 方法设置为 HTTP 请求方法。
httpRequest.requestSize network.sent_bytes 转换为 uinteger。
httpRequest.requestUrl network.http.referral_url 网络 HTTP 引荐来源网址设置为 HTTP 请求网址。
httpRequest.responseSize network.received_bytes 转换为 uinteger。
httpRequest.serverIp principal.ip 如果存在此值,且未设置其他主 IP,则使用此值。
httpRequest.status network.http.response_code 已转换为整数。
httpRequest.userAgent network.http.user_agent 网络 HTTP 用户代理设置为 HTTP 请求用户代理。
insertId network.session_id 网络会话 ID 设置为插播 ID。
jsonPayload.@metadata.beat metadata.product_event_type 元数据商品事件类型设置为元数据节拍。
jsonPayload.@metadata.version metadata.product_version 元数据商品版本设置为元数据版本。
jsonPayload.destination.ip target.ip 如果存在此参数,且未设置其他目标 IP,则使用此值。
jsonPayload.destination.port target.port 如果存在此值,且未设置其他目标端口,则使用此值。已转换为整数。
jsonPayload.event1.category security_result.category_details 所有值都会添加到 category_details 中。
jsonPayload.file.path target.file.full_path 如果存在此值,且未设置其他目标路径,则使用此值。
jsonPayload.process.executable principal.process.file.full_pathtarget.process.file.full_path 用于在没有其他值的情况下设置主进程和目标进程的完整路径。
jsonPayload.process.name principal.application 如果存在此值,且未设置其他主应用,则使用此值。
jsonPayload.process.parent.pid principal.process.pid 如果存在此值,且未设置其他主要进程 PID,则使用此值。已转换为字符串。
jsonPayload.process.parent.ppid principal.process.parent_process.pid 如果存在此值,且未设置其他主父进程 PID,则使用此值。已转换为字符串。
jsonPayload.process.parent.process.executable principal.process.file.full_path 如果存在,且未设置其他主进程完整路径,则使用此值。
jsonPayload.process.parent.process.exe principal.process.file.full_path 如果存在,且未设置其他主进程完整路径,则使用此值。
jsonPayload.process.parent.process.title principal.process.command_line 如果存在此值,且未设置其他主进程命令行,则使用此值。
jsonPayload.process.pid target.process.pid 目标进程 PID 设置为 JSON 载荷进程 PID。
jsonPayload.process.title target.process.command_line 目标进程命令行设置为 JSON 载荷进程标题。
jsonPayload.user.id target.user.userid 如果存在此值,且未设置其他目标用户 ID,则使用此值。已转换为字符串。
jsonPayload.user.name target.user.user_display_name 如果存在此值,且未设置其他目标用户显示名称,则使用此值。
msg metadata.description 元数据说明已设置为相应消息。
network.bytes network.sent_bytes 转换为 uinteger。
network.community_id network.community_id 网络社区 ID 设置为网络社区 ID。
network.transport network.ip_protocol 已转换为大写。
package.description security_result.description 安全结果说明已设置为软件包说明。
package.name security_result.rule_name 安全结果规则名称设置为软件包名称。
package.reference security_result.about.url 安全结果网址已设置为软件包引用。
package.size security_result.about.file.size 转换为 uinteger。
package.type security_result.about.file.mime_typesecurity_result.rule_type 安全结果 MIME 类型和规则类型设置为软件包类型。
process.created principal.asset.creation_time 如果存在,则使用此值。解析为 ISO8601。
process.entity_id principal.process.product_specific_process_id 以“Process:”为前缀。
process.executable principal.process.file.full_pathtarget.process.file.full_path 用于在没有其他值的情况下设置主进程和目标进程的完整路径。
process.hash.sha1 principal.process.file.sha1 将主进程 SHA-1 设置为进程 SHA-1 哈希。
process.name principal.application 如果存在此值,且未设置其他主应用,则使用此值。
process.pid principal.process.pid 如果存在此值,且未设置其他主要进程 PID,则使用此值。已转换为字符串。
process.ppid principal.process.parent_process.pid 如果存在此值,且未设置其他主父进程 PID,则使用此值。已转换为字符串。
process.start principal.asset.creation_time 如果不存在 process.created,但存在此字段,则使用此值。解析为 ISO8601。
resource.labels.backend_service_name target.resource.name 目标资源名称设置为资源后端服务名称。
resource.labels.forwarding_rule_name target.resource.attribute.labels 添加为标签,键为“转发规则名称”。
resource.labels.project_id target.resource.product_object_id 目标资源商品对象 ID 设置为资源项目 ID。
resource.labels.target_proxy_name target.resource.attribute.labels 添加为标签,键为“目标代理名称”。
resource.labels.url_map_name target.resource.attribute.labels 添加为具有键“网址映射名称”的标签。
server.bytes intermediary.labels 以键“Bytes”的形式添加为标签。已转换为字符串。
server.ip intermediary.ip 中介 IP 设置为服务器 IP。
server.packets intermediary.labels 添加为键为“数据包”的标签。已转换为字符串。
server.port intermediary.port 中介端口设置为服务器端口。已转换为整数。
service.type target.application 目标应用设置为服务类型。
source.bytes src.labels 以键“Bytes”的形式添加为标签。已转换为字符串。
source.ip src.ip 来源 IP 设置为来源 IP。
source.packets src.labels 添加为键为“数据包”的标签。已转换为字符串。
source.port src.port 来源端口设置为来源端口。已转换为整数。
system.audit.host.boottime about.asset.last_boot_time 解析为 ISO8601。
system.audit.host.hostname about.hostname “关于”主机名设置为系统审核主机名。
system.audit.host.id principal.user.userid 主用户 ID 设置为系统审核宿主 ID。
system.audit.host.mac.0 about.mac 将 about MAC 地址设置为第一个系统审核主机 MAC 地址。
trace target.process.file.full_path 如果存在此值,且未设置其他目标进程完整路径,则使用此值。
user.effective.id target.user.userid 如果存在此值,且未设置其他目标用户 ID,则使用此值。
user.effective.name target.user.user_display_name 如果存在此值,且未设置其他目标用户显示名称,则使用此值。
user.id target.user.userid 如果存在此值,且未设置其他目标用户 ID,则使用此值。已转换为字符串。
user.name target.user.user_display_name 如果存在此值,且未设置其他目标用户显示名称,则使用此值。
不适用 metadata.event_type 最初设置为“GENERIC_EVENT”。根据解析器代码注释中描述的逻辑进行了更改。
不适用 metadata.log_type 设置为“ELASTIC_AUDITBEAT”。
不适用 metadata.product_name 设置为“Auditbeat”。
不适用 metadata.vendor_name 设置为“弹性”。
不适用 extensions.auth.type 对于 USER_LOGIN 和 USER_LOGOUT 事件,设置为“AUTHTYPE_UNSPECIFIED”。
auditd.data.syscall metadata.product_event_type 元数据商品事件类型设置为 auditd 系统调用。

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