收集 HAProxy 日志

支持:

本文档介绍了如何使用 Bindplane 代理将 HAProxy 日志注入 Google Security Operations。

HAProxy 是一种高可用性负载均衡器和代理服务器,可为 HTTP 请求、连接事件、后端健康检查和进程活动生成 syslog 消息。解析器使用 Grok 模式匹配从各种 HAProxy 日志格式中提取字段,并将其映射到统一数据模型 (UDM)。

准备工作

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

  • Google SecOps 实例
  • Windows Server 2016 或更高版本,或者具有 systemd 的 Linux 主机
  • Bindplane 代理与 HAProxy 服务器之间的网络连接
  • 如果通过代理运行,请确保防火墙端口根据 Bindplane 代理要求打开
  • 对 HAProxy 配置的管理员访问权限

获取 Google SecOps 注入身份验证文件

  1. 登录 Google SecOps 控制台。
  2. 前往 SIEM 设置 > 收集代理
  3. 下载注入身份验证文件
  4. 将该文件安全地保存在将安装 Bindplane 代理的系统上。

获取 Google SecOps 客户 ID

  1. 登录 Google SecOps 控制台。
  2. 前往 SIEM 设置 > 个人资料
  3. 组织详细信息 部分复制并保存客户 ID

安装 Bindplane 代理

按照以下说明在 Windows 或 Linux 操作系统上安装 Bindplane 代理。

Windows 安装

  1. 以管理员身份打开命令提示符PowerShell
  2. 运行以下命令:

    msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
    
  3. 等待安装完成。

  4. 运行以下命令,验证安装是否成功:

    sc query observiq-otel-collector
    

    该服务应显示为正在运行

Linux 安装

  1. 使用 root 或 sudo 权限打开终端。
  2. 运行以下命令:

    sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
    
  3. 等待安装完成。

  4. 运行以下命令,验证安装是否成功:

    sudo systemctl status observiq-otel-collector
    

    该服务应显示为活跃 (running)

其他安装资源

如需了解其他安装选项和问题排查,请参阅 Bindplane 代理安装指南

配置 Bindplane 代理以注入 syslog 并发送到 Google SecOps

找到配置文件

  • Linux

    sudo nano /etc/bindplane-agent/config.yaml
    
  • Windows

    notepad "C:\Program Files\observIQ OpenTelemetry Collector\config.yaml"
    

修改配置文件

  • config.yaml 的全部内容替换为以下配置:

    receivers:
        udplog:
            listen_address: "0.0.0.0:514"
    
    exporters:
        chronicle/haproxy:
            compression: gzip
            creds_file_path: '/etc/bindplane-agent/ingestion-auth.json'
            customer_id: '<customer_id>'
            endpoint: malachiteingestion-pa.googleapis.com
            log_type: HAPROXY
            raw_log_field: body
    
    service:
        pipelines:
            logs/haproxy_to_chronicle:
                receivers:
                    - udplog
                exporters:
                    - chronicle/haproxy
    

配置参数

替换以下占位符:

  • 接收器配置

    • listen_address:要监听的 IP 地址和端口:
      • 0.0.0.0 以监听所有接口(推荐)
      • 端口 514 是标准 syslog 端口(在 Linux 上需要 root;对于非 root 用户,请使用 1514
  • 导出器配置

    • creds_file_path:注入身份验证文件的完整路径:
      • Linux: /etc/bindplane-agent/ingestion-auth.json
      • Windows: C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json
    • customer_id:从 Google SecOps 控制台复制的客户 ID
    • endpoint:区域级端点网址:
      • 美国malachiteingestion-pa.googleapis.com
      • 欧洲: europe-malachiteingestion-pa.googleapis.com
      • 亚洲: asia-southeast1-malachiteingestion-pa.googleapis.com
      • 如需查看完整列表,请参阅区域级端点

保存配置文件

  • 修改后,保存文件:
    • Linux:按 Ctrl+O,然后按 Enter,再按 Ctrl+X
    • Windows:依次点击文件 > 保存

重启 Bindplane 代理以应用更改

  • 如需在 Linux 中重启 Bindplane 代理,请运行以下命令:

    sudo systemctl restart observiq-otel-collector
    
    1. 验证服务正在运行:

      sudo systemctl status observiq-otel-collector
      
    2. 检查日志中的错误:

      sudo journalctl -u observiq-otel-collector -f
      
  • 如需在 Windows 中重启 Bindplane 代理,请选择以下选项之一:

    • 以管理员身份运行命令提示符或 PowerShell:

      net stop observiq-otel-collector && net start observiq-otel-collector
      
    • 服务控制台:

      1. Win+R,输入 services.msc,然后按 Enter 键。
      2. 找到 observIQ OpenTelemetry Collector
      3. 右键点击并选择重启
      4. 验证服务正在运行:

        sc query observiq-otel-collector
        
      5. 检查日志中的错误:

        type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
        

为 HAProxy 配置 syslog

  1. 使用 CLI 登录 HAProxy
  2. global 部分的配置 中添加 log 指令,以通过 UDP 转发 syslog 消息。

    • <bindplane-ip> 替换为实际的 Bindplane 代理 IP 地址。
    global
        log <bindplane-ip>:514 local0
    
    defaults
        log global
    

UDM 映射表

日志字段 UDM 映射 逻辑
accept_date_ms
actconn
backend_name
backend_queue
beconn
bytes_read network.received_bytes 从日志中的 bytes_read 字段提取,并转换为无符号整数。
captured_request_headers
client_ip principal.ip 从日志中的 client_ip 字段提取。
client_port principal.port 从日志中的 client_port 字段提取,并转换为整数。
command_description metadata.description 从日志中的 command_description 字段提取(如果有)。否则,它会根据日志消息从其他字段(例如 actionstatus)派生。
datetime metadata.event_timestamp.seconds 从日志中的 datetime 字段提取(如果有)。否则,它会从日志条目中的 timestamp 字段派生。
description metadata.description 从日志中的 description 字段提取(如果有)。否则,它会根据日志消息从其他字段(例如 command_descriptionaction)派生。
feconn
frontend_name
http_request target.url 从日志中的 http_request 字段提取。
http_status_code network.http.response_code 从日志中的 http_status_code 字段提取,并转换为整数。
http_verb network.http.method 从日志中的 http_verb 字段提取。
http_version metadata.product_version 从日志中的 http_version 字段提取,并格式化为 HTTP/{version}
initiator target.application 从日志中的 initiator 字段提取。
module
msg security_result.summary 从日志中的 msg 字段提取。
pid target.process.pid 从日志中的 pid 字段提取。
process
process_name target.application 从日志中的 process_name 字段提取。
retries
server_name target.hostname 从日志中的 server_name 字段提取。如果为空,则默认为 syslog_server 的值。
severity security_result.severity 从日志中的 severity 字段映射。WARNING 映射到 MEDIUMALERT 映射到 CRITICALNOTICE 映射到 INFORMATIONAL
shell
srv_queue
srvconn
status
syslog_server target.hostname, intermediary.hostname 从日志中的 syslog_server 字段提取。同时用于目标主机名(如果 server_name 为空)和中间主机名。
syslog_timestamp
syslog_timestamp_1
syslog_timestamp_2
syslog_timestamp_4
target_ip
time_backend_connect
time_backend_response
time_duration
time_queue
time_request
timestamp metadata.event_timestamp.seconds 从日志中的 timestamp 字段提取,并解析日期和时间信息。用作事件时间戳。
unknown_parameters1
unknown_parameters2
user_name target.user.userid 从日志中的 user_name 字段提取。
metadata.event_type 默认设置为 NETWORK_HTTP。根据日志消息和解析的字段更改为特定事件类型,例如 PROCESS_UNCATEGORIZEDSTATUS_UPDATEUSER_UNCATEGORIZED
metadata.vendor_name 设置为 HAProxy Enterprise
metadata.product_name 设置为 HAProxy
network.application_protocol 如果 message 字段包含 HTTP,则设置为 HTTP
metadata.log_type 设置为 HAPROXY

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