收集 HAProxy 日志
支持的平台:
Google secops
Siem
本文档介绍了如何使用 Bindplane 将 HAProxy 日志注入到 Google 安全运营团队。Logstash 解析器使用一系列 Grok 模式匹配规则从 HAProxy syslog 消息中提取字段,这些规则专门用于处理各种 HAProxy 日志格式。然后,它会将提取的字段映射到统一数据模型 (UDM),使用额外的上下文丰富数据,并标准化表示法以进行进一步分析。
准备工作
请确保满足以下前提条件:
- Google SecOps 实例
- Windows 2016 或更高版本,或搭载
systemd
的 Linux 主机 - 如果在代理后运行,防火墙端口处于打开状态
- 对 HAProxy 的特权访问权限
获取 Google SecOps 提取身份验证文件
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 收集代理。
- 下载提取身份验证文件。将该文件安全地保存在将安装 BindPlane 的系统上。
获取 Google SecOps 客户 ID
- 登录 Google SecOps 控制台。
- 依次选择 SIEM 设置 > 配置文件。
- 复制并保存组织详细信息部分中的客户 ID。
安装 Bindplane 代理
Windows 安装
- 以管理员身份打开命令提示符或 PowerShell。
运行以下命令:
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
Linux 安装
- 打开具有 root 或 sudo 权限的终端。
运行以下命令:
sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
其他安装资源
如需了解其他安装选项,请参阅安装指南。
配置 Bindplane 代理以注入 Syslog 并将其发送到 Google SecOps
- 访问配置文件:
- 找到
config.yaml
文件。通常,在 Linux 上,该目录位于/etc/bindplane-agent/
目录中;在 Windows 上,该目录位于安装目录中。 - 使用文本编辑器(例如
nano
、vi
或记事本)打开该文件。
- 找到
按如下方式修改
config.yaml
文件:receivers: udplog: # Replace the port and IP address as required listen_address: "0.0.0.0:514" exporters: chronicle/chronicle_w_labels: compression: gzip # Adjust the path to the credentials file you downloaded in Step 1 creds_file_path: '/path/to/ingestion-authentication-file.json' # Replace with your actual customer ID from Step 2 customer_id: <customer_id> endpoint: malachiteingestion-pa.googleapis.com # Add optional ingestion labels for better organization ingestion_labels: log_type: 'HAPROXY' raw_log_field: body service: pipelines: logs/source0__chronicle_w_labels-0: receivers: - udplog exporters: - chronicle/chronicle_w_labels
根据基础架构中的需要替换端口和 IP 地址。
将
<customer_id>
替换为实际的客户 ID。将
/path/to/ingestion-authentication-file.json
更新为获取 Google SecOps 提取身份验证文件部分中身份验证文件的保存路径。
重启 Bindplane 代理以应用更改
如需在 Linux 中重启 Bindplane 代理,请运行以下命令:
sudo systemctl restart bindplane-agent
如需在 Windows 中重启 Bindplane 代理,您可以使用服务控制台,也可以输入以下命令:
net stop BindPlaneAgent && net start BindPlaneAgent
为 HAProxy 配置 Syslog
- 使用 CLI 登录 HAproxy。
将 global 部分中的 log 指令添加到 Configuration,以便通过 UDP 转发 Syslog 消息。
- 将
<bindplane-ips>
替换为实际的 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 字段(如果有)中提取。否则,它会从其他字段(例如 action 或 status )派生,具体取决于日志消息。 |
datetime | metadata.event_timestamp.seconds | 从日志中的 datetime 字段(如果有)中提取。否则,它会从日志条目中的 timestamp 字段派生而来。 |
说明 | metadata.description | 从日志中的 description 字段(如果有)中提取。否则,它会从其他字段(例如 command_description 或 action )派生,具体取决于日志消息。 |
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} 。 |
发起者 | target.application | 从日志中的 initiator 字段中提取。 |
module | ||
msg | security_result.summary | 从日志中的 msg 字段中提取。 |
pid | target.process.pid | 从日志中的 pid 字段中提取。 |
原始事件 | ||
process_name | target.application | 从日志中的 process_name 字段中提取。 |
retries | ||
server_name | target.hostname | 从日志中的 server_name 字段中提取。如果为空,则默认为 syslog_server 的值。 |
和程度上减少 | security_result.severity | 从日志中的 severity 字段映射而来。WARNING 映射到 MEDIUM 、ALERT 映射到 CRITICAL ,NOTICE 映射到 INFORMATIONAL 。 |
shell | ||
srv_queue | ||
srvconn | ||
状态 | ||
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 | ||
时间戳 | metadata.event_timestamp.seconds | 从日志中的 timestamp 字段中提取,并解析出日期和时间信息。用作事件时间戳。 |
unknown_parameters1 | ||
unknown_parameters2 | ||
user_name | target.user.userid | 从日志中的 user_name 字段中提取。 |
metadata.event_type | 默认设置为 NETWORK_HTTP 。根据日志消息和解析的字段更改为特定事件类型,例如 PROCESS_UNCATEGORIZED 、STATUS_UPDATE 或 USER_UNCATEGORIZED 。 |
|
metadata.vendor_name | 设置为 HAProxy Enterprise 。 |
|
metadata.product_name | 设置为 HAProxy 。 |
|
network.application_protocol | 如果 message 字段包含 HTTP ,则设置为 HTTP 。 |
|
metadata.log_type | 设置为 HAPROXY 。 |
需要更多帮助?向社区成员和 Google SecOps 专业人士寻求解答。