收集 NGINX 日志
支持的平台:
Google SecOps
SIEM
此 NGINX 解析器可处理 JSON 和 syslog 格式的日志。它会从各种日志格式中提取字段,并将其标准化为 UDM 格式。解析器会使用服务器管理和网络活动(包括用户登录和 HTTP 请求)的元数据来丰富事件。它还会处理 SSH 事件的逻辑,并根据提取的数据填充 UDM 字段。
准备工作
- 确保您有一个 Google Security Operations 实例。
- 确保 NGINX 正在运行并生成日志。
- 确保您拥有对 NGINX 主机的 root 访问权限。
获取 Google SecOps 提取身份验证文件
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 收集代理。
- 下载提取身份验证文件。
获取 Google SecOps 客户 ID
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 配置文件。
- 复制并保存组织详细信息部分中的客户 ID。
安装 BindPlane Agent
- 对于 Windows 安装,请运行以下脚本:
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
- 对于 Linux 安装,请运行以下脚本:
sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
- 如需了解其他安装选项,请参阅此安装指南。
配置 BindPlane 代理以提取 Syslog 并将其发送到 Google SecOps
- 访问安装了 BindPlane 的机器。
按如下方式修改
config.yaml
文件:receivers: tcplog: # Replace the below port <54525> and IP <0.0.0.0> with your specific values listen_address: "0.0.0.0:54525" exporters: chronicle/chronicle_w_labels: compression: gzip # Adjust the creds location below according the placement of the credentials file you downloaded creds: '{ json file for creds }' # Replace <customer_id> below with your actual ID that you copied customer_id: <customer_id> endpoint: malachiteingestion-pa.googleapis.com # You can apply ingestion labels below as preferred ingestion_labels: log_type: SYSLOG namespace: auditd raw_log_field: body service: pipelines: logs/source0__chronicle_w_labels-0: receivers: - tcplog exporters: - chronicle/chronicle_w_labels
重启 BindPlane 代理以应用更改:
sudo systemctl restart bindplane
确定 NGINX 日志文件的位置
NGINX 日志存储在:
* 访问日志:/var/log/nginx/access.log
* 错误日志:/var/log/nginx/error.log
1. 使用管理员凭据访问 NGINX 主机。
1. 运行以下命令,然后在 NGINX 主机上查找日志文件路径:
sudo cat /etc/nginx/nginx.conf | grep log
配置 NGINX 以将日志转发到 BindPlane
打开 NGINX 配置文件(例如
/etc/nginx/nginx.conf
):sudo vi /etc/nginx/nginx.conf
修改配置,将
<BINDPLANE_SERVER>
和<BINDPLANE_PORT>
替换为您的值:http { access_log syslog:server=<BINDPLANE_SERVER>:<BINDPLANE_PORT>,facility=local7,tag=nginx_access; error_log syslog:server=<BINDPLANE_SERVER>:<BINDPLANE_PORT>,facility=local7,tag=nginx_error; }
重启 NGINX 以应用更改:
sudo systemctl reload nginx
UDM 映射表
日志字段 | UDM 映射 | 逻辑 |
---|---|---|
_Internal_WorkspaceResourceId |
target.resource.product_object_id |
直接映射 |
Computer |
principal.asset.hostname |
直接映射 |
Facility |
additional.fields["facility"] |
直接映射 |
HostName |
principal.asset.hostname |
如果不存在 src_ip ,则直接映射 |
ProcessName |
principal.application |
直接映射 |
SeverityLevel |
security_result.severity |
如果值为“info”,则映射到“INFORMATIONAL” |
SourceSystem |
principal.asset.platform |
如果值与“Linux”匹配,则映射到 LINUX |
SyslogMessage |
多个字段 | 使用 grok 进行解析,以提取 time 、method 、target_path 、protocol 、response_code 、referral_url 、user_agent 、target_ip 、target_host 和 cache |
TenantId |
additional.fields["TenantId"] |
直接映射 |
acct |
principal.user.user_id |
如果不为空或“?”,则直接映射 |
addr |
principal.asset.ip |
直接映射 |
audit_epoch |
metadata.event_timestamp |
使用“UNIX”格式转换为时间戳。纳秒数会从原始日志消息中提取。 |
cache |
additional.fields["cache"] |
直接映射 |
collection_time.nanos |
metadata.event_timestamp.nanos |
用于事件时间戳的纳秒数(如果有) |
collection_time.seconds |
metadata.event_timestamp.seconds |
用于事件时间戳(如果有)的秒数 |
data |
多个字段 | 数据的主要来源,会根据日志格式(Syslog、JSON 或其他)以不同的方式解析 |
exe |
target.process.command_line |
移除反斜杠和引号后直接映射 |
hostname |
principal.asset.hostname 或 principal.asset.ip |
如果是 IP 地址,则映射到 principal.asset.ip 。否则,映射到 principal.asset.hostname |
msg |
metadata.description |
直接映射为说明 |
node |
target.asset.hostname |
直接映射 |
pid |
target.process.pid |
直接映射 |
protocol |
network.application_protocol |
如果值与“HTTP”匹配,则映射到 HTTP |
referral_url |
network.http.referral_url |
如果不为空或“-”,则直接映射 |
res |
security_result.action_details |
直接映射 |
response_code |
network.http.response_code |
直接映射并转换为整数 |
ses |
network.session_id |
直接映射 |
src_ip |
principal.asset.ip |
直接映射 |
target_host |
target.asset.hostname |
直接映射 |
target_ip |
target.asset.ip |
直接映射,即将字符串表示形式转换为 JSON 数组,然后提取各个 IP |
target_path |
target.url |
直接映射 |
time |
metadata.event_timestamp |
会解析以“dd/MMM/yyyy:HH:mm:ss Z”格式提取时间戳 |
user_agent |
network.http.user_agent |
如果不为空或“-”,则直接映射 |
metadata.event_type |
最初设为“GENERIC_EVENT”,然后可能会根据 terminal 和 protocol 等其他字段进行覆盖。如果主 Grok 模式不匹配,则默认为“USER_UNCATEGORIZED”。如果 protocol 为 HTTP 且存在 target_ip ,则设置为“NETWORK_HTTP”;如果 protocol 为 HTTP 但不存在 target_ip ,则设置为“STATUS_UPDATE” |
|
metadata.log_type |
设置为“NGINX” | |
metadata.product_name |
设置为“NGINX” | |
metadata.vendor_name |
设置为“NGINX” | |
network.ip_protocol |
如果 terminal 为“sshd”或“ssh”,或者主 Grok 模式不匹配,则设置为“TCP” |
|
principal.asset_id |
如果 terminal 为“sshd”或“ssh”,则设置为“GCP.GCE:0001”。如果主 Grok 模式不匹配,则设置为“GCP.GCE:0002” |
|
extensions.auth.type |
如果 terminal 为“sshd”或“ssh”,则设置为“MACHINE” |
更改
2022-09-10
- 创建了默认解析器,并删除了特定于客户的解析器。
- 初始解析器版本。