收集 Apache 日志
本文档介绍了如何使用 Bindplane 代理将 Apache 日志注入到 Google Security Operations。
Apache HTTP Server 是一款开源 Web 服务器,可处理 HTTP 请求并生成访问日志和错误日志。解析器可处理标准组合/通用日志格式和 JSON 格式的日志,并提取 HTTP 请求详细信息、响应代码和客户端信息。
准备工作
请确保满足以下前提条件:
- Google SecOps 实例
- Windows Server 2016 或更高版本,或者具有
systemd的 Linux 主机 - Bindplane 代理与 Apache 服务器之间的网络连接
- 如果通过代理运行,请确保防火墙端口已根据 Bindplane 代理要求打开
- 对 Apache 服务器的特权访问权限(root 或 sudo)
获取 Google SecOps 注入身份验证文件
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 收集代理。
- 下载注入身份验证文件。
将文件安全地保存在将要安装 Bindplane 代理的系统上。
获取 Google SecOps 客户 ID
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 配置文件。
复制并保存组织详细信息部分中的客户 ID。
安装 Bindplane 代理
按照以下说明在 Windows 或 Linux 操作系统上安装 Bindplane 代理。
Windows 安装
- 以管理员身份打开命令提示符或 PowerShell。
运行以下命令:
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet等待安装完成。
运行以下命令,验证安装是否成功:
sc query observiq-otel-collector该服务应显示为 RUNNING。
Linux 安装
- 打开具有 root 或 sudo 权限的终端。
运行以下命令:
sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh等待安装完成。
运行以下命令,验证安装是否成功:
sudo systemctl status observiq-otel-collector该服务应显示为有效(正在运行)。
其他安装资源
如需了解其他安装选项和问题排查信息,请参阅 Bindplane 代理安装指南。
配置 Bindplane 代理以注入 syslog 并将其发送到 Google SecOps
找到配置文件
Linux:
sudo nano /etc/bindplane-agent/config.yamlWindows:
notepad "C:\Program Files\observIQ OpenTelemetry Collector\config.yaml"
修改配置文件
将
config.yaml的全部内容替换为以下配置:receivers: udplog: listen_address: "0.0.0.0:514" exporters: chronicle/apache: compression: gzip creds_file_path: '/etc/bindplane-agent/ingestion-auth.json' customer_id: '<customer_id>' endpoint: malachiteingestion-pa.googleapis.com log_type: APACHE raw_log_field: body service: pipelines: logs/apache_to_chronicle: receivers: - udplog exporters: - chronicle/apache
配置参数
替换以下占位符:
接收器配置:
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
- Linux:
customer_id:从 Google SecOps 控制台复制的客户 IDendpoint:区域端点网址:- 美国:
malachiteingestion-pa.googleapis.com - 欧洲:
europe-malachiteingestion-pa.googleapis.com - 亚洲:
asia-southeast1-malachiteingestion-pa.googleapis.com - 如需查看完整列表,请参阅区域级端点
- 美国:
保存配置文件
- 修改后,保存文件:
- Linux:依次按
Ctrl+O、Enter和Ctrl+X - Windows:依次点击文件 > 保存
- Linux:依次按
重启 Bindplane 代理以应用更改
如需在 Linux 中重启 Bindplane 代理,请运行以下命令:
sudo systemctl restart observiq-otel-collector验证服务是否正在运行:
sudo systemctl status observiq-otel-collector检查日志是否存在错误:
sudo journalctl -u observiq-otel-collector -f
如需在 Windows 中重启 Bindplane 代理,请选择以下选项之一:
以管理员身份运行命令提示符或 PowerShell:
net stop observiq-otel-collector && net start observiq-otel-collector服务控制台:
- 按
Win+R,输入services.msc,然后按 Enter 键。 - 找到 observIQ OpenTelemetry 收集器。
- 右键点击并选择重新启动。
验证服务是否正在运行:
sc query observiq-otel-collector检查日志是否存在错误:
type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
- 按
在 Apache 中配置 syslog
- 使用 SSH 登录托管 Apache 的服务器。
在
/etc/rsyslog.d/下创建一个名为02-apache2.conf的文件:vim /etc/rsyslog.d/02-apache2.conf在文件中添加以下代码:
module(load="imfile" PollingInterval="10" statefile.directory="/var/spool/rsyslog") input(type="imfile" File="/var/log/apache2/access.log" Tag="http_access" Severity="info" Facility="local6") Local6.info @<BINDPLANE_IP>:<BINDPLANE_PORT> module(load="imfile" PollingInterval="10" statefile.directory="/var/spool/rsyslog") input(type="imfile" File="/var/log/apache2/error.log" Tag="http_error" Severity="error" Facility="local7") Local7.error @<BINDPLANE_IP>:<BINDPLANE_PORT>- 将
<BINDPLANE_IP>和<BINDPLANE_PORT>替换为为 Bindplane 代理配置的 IP 地址和端口。 - 如果您使用的是 TCP 协议,请在主机行中附加一个额外的
@(例如@@<BINDPLANE_IP>:<BINDPLANE_PORT>)。
- 将
重启 rsyslog 服务:
sudo service rsyslog restart
UDM 映射表
| 日志字段 | UDM 映射 | 逻辑 |
|---|---|---|
bytes |
network.received_bytes |
从客户端接收的字节数。 |
bytes |
network.sent_bytes |
发送到客户端的字节数。 |
bytes_out |
network.sent_bytes |
发送到客户端的字节数。 |
bytes_received |
network.received_bytes |
从客户端接收的字节数。 |
Content |
network.http.method |
从“内容”字段中提取的 HTTP 方法。 |
Content |
target.url |
从“内容”字段中提取的目标网址。 |
cookie |
additional.fields.value.string_value |
“cookie”字段的值。 |
dest_ip |
target.ip |
目标的 IP 地址。 |
dest_name |
target.hostname |
目标的 hostname。 |
dest_port |
target.port |
目标端口。 |
description |
metadata.description |
事件的说明。 |
duration_microseconds |
additional.fields.value.string_value |
“duration_microseconds”字段的值。 |
file_full_path |
target.file.full_path |
目标文件的完整路径。 |
hostname |
target.hostname |
目标的 hostname。 |
http_content_type |
additional.fields.value.string_value |
“http_content_type”字段的值。 |
http_host |
principal.hostname |
主账号的主机名。 |
http_method |
network.http.method |
HTTP 方法。 |
http_referrer |
network.http.referral_url |
HTTP 引荐来源网址。 |
http_user_agent |
network.http.user_agent |
HTTP 用户代理。 |
ID |
metadata.id |
活动的 ID。 |
insertId |
metadata.product_log_id |
商品日志 ID。 |
ip |
principal.ip |
主账号的 IP 地址。 |
jsonPayload.cIP |
target.ip |
目标的 IP 地址。 |
jsonPayload.cPort |
target.port |
目标端口。 |
jsonPayload.csBytes |
network.sent_bytes |
发送到客户端的字节数。 |
jsonPayload.csMethod |
network.http.method |
HTTP 方法。 |
jsonPayload.csMimeType |
target.file.mime_type |
目标文件的 MIME 类型。 |
jsonPayload.csReferer |
network.http.referral_url |
HTTP 引荐来源网址。 |
jsonPayload.csURL |
target.url |
目标网址。 |
jsonPayload.csUserAgent |
network.http.user_agent |
HTTP 用户代理。 |
jsonPayload.sHierarchy |
additional.fields.value.string_value |
“sHierarchy”字段的值。 |
jsonPayload.sHostname |
principal.hostname |
主账号的主机名。 |
jsonPayload.sIP |
principal.ip |
主账号的 IP 地址。 |
jsonPayload.scBytes |
network.received_bytes |
从客户端接收的字节数。 |
jsonPayload.scHTTPStatus |
network.http.response_code |
HTTP 响应代码。 |
jsonPayload.scResultCode |
additional.fields.value.string_value |
“scResultCode”字段的值。 |
LastStatus |
network.http.response_code |
HTTP 响应代码。 |
log_level |
security_result.severity |
安全结果的严重程度。 |
logName |
security_result.category_details |
安全结果的类别详细信息。 |
method |
network.http.method |
HTTP 方法。 |
pid |
principal.process.pid |
主账号的进程 ID。 |
Port |
target.port |
目标端口。 |
proto |
network.application_protocol |
应用协议。 |
referer |
network.http.referral_url |
HTTP 引荐来源网址。 |
RemoteHost |
principal.ip |
主账号的 IP 地址。 |
RemoteUser |
principal.user.userid |
主账号的用户 ID。 |
resource.labels.instance_id |
target.resource.product_object_id |
目标资源的商品对象 ID。 |
resource.labels.project_id |
target.resource.attribute.labels.value |
“project_id”标签的值。 |
resource.labels.zone |
target.resource.attribute.cloud.availability_zone |
目标资源的可用区。 |
resource.type |
target.resource.resource_type |
目标的资源类型。 |
response |
network.http.response_code |
HTTP 响应代码。 |
SizeBytes |
network.received_bytes |
从客户端接收的字节数。 |
src_ip |
principal.ip |
主账号的 IP 地址。 |
src_port |
principal.port |
主账号的端口。 |
ssl_cipher |
network.tls.cipher |
TLS 加密。 |
ssl_version |
network.tls.version_protocol |
TLS 版本协议。 |
status |
network.http.response_code |
HTTP 响应代码。 |
target |
target.url |
目标网址。 |
target_ip |
target.ip |
目标的 IP 地址。 |
target_port |
target.port |
目标端口。 |
time |
metadata.event_timestamp |
事件时间戳。 |
uri_path |
target.process.file.full_path |
目标文件的完整路径。 |
user |
principal.user.userid |
主账号的用户 ID。 |
useragent |
network.http.user_agent |
HTTP 用户代理。 |
version_protocol |
network.tls.version_protocol |
TLS 版本协议。 |
Workername |
principal.hostname |
主账号的主机名。 |
x_forwarded_for |
“X-Forwarded-For”标头的值。 | |
metadata.log_type |
该值在解析器代码中设置为“APACHE”。 | |
metadata.product_name |
该值在解析器代码中设置为“Apache Web Server”。 | |
metadata.vendor_name |
该值在解析器代码中设置为“Apache”。 | |
metadata.event_type |
该值根据委托人和目标信息是否存在来确定。如果主账号和目标账号都存在,则事件类型设置为“NETWORK_HTTP”。如果仅存在委托人,则将事件类型设置为“STATUS_UPDATE”。否则,该值会设置为“GENERIC_EVENT”。 | |
additional.fields.key |
在解析器代码中,根据相应字段将键设置为“keep_alive”“duration_microseconds”“cookie”“http_content_type”“sHierarchy”“scResultCode”。 | |
target.port |
如果“proto”字段为“HTTP”,则端口设置为 80。如果“proto”字段为“HTTPS”,则端口设置为 443。如果“proto”字段为“FTP”,则端口设置为 21。 | |
target.resource.attribute.labels.key |
该键在解析器代码中设置为“project_id”。 |
需要更多帮助?获得社区成员和 Google SecOps 专业人士的解答。