收集 MySQL 日志
本文档介绍了如何使用 Bindplane 代理将 MySQL 日志注入到 Google Security Operations。
MySQL 是一种关系型数据库管理系统,可针对身份验证事件、查询执行、数据库操作和审核轨迹条目生成 syslog 消息。解析器会从 syslog 格式的审核日志中提取字段,并将其映射到统一数据模型 (UDM)。
准备工作
请确保满足以下前提条件:
- Google SecOps 实例
- Windows Server 2016 或更高版本,或者具有
systemd的 Linux 主机 - Bindplane 代理与 MySQL 服务器之间的网络连接
- 如果在代理后面运行,请确保防火墙端口已根据 Bindplane 代理要求打开
- 对 MySQL 主机的 SSH 访问权限(具有 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该服务应显示为 正在运行。
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 /opt/observiq-otel-collector/config.yamlWindows:
notepad "C:\Program Files\observIQ OpenTelemetry Collector\config.yaml"
修改配置文件
将
config.yaml的全部内容替换为以下配置:receivers: udplog: listen_address: "0.0.0.0:514" exporters: chronicle/mysql: compression: gzip creds_file_path: '/etc/bindplane-agent/ingestion-auth.json' customer_id: '<customer_id>' endpoint: malachiteingestion-pa.googleapis.com log_type: MYSQL raw_log_field: body service: pipelines: logs/mysql_to_chronicle: receivers: - udplog exporters: - chronicle/mysql
配置参数
替换以下占位符:
接收器配置:
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"
- 按
在 MySQL 中配置 syslog
- 使用 SSH 登录 MySQL 主机。
连接到 MySQL 数据库:
mysql -u root -p验证
server_audit.so审核插件:show variables like 'plugin_dir';如果未找到该插件,请进行安装:
install plugin server_audit soname 'server_audit.so';确认插件已安装并已启用:
show plugins;修改文件
/etc/my.cnf并启用以下审核设置:server_audit_events='CONNECT,QUERY,TABLE' server_audit_file_path=server_audit.log server_audit_logging=ON server_audit_output_type=SYSLOG server_audit_syslog_facility=LOG_LOCAL6验证审核变量:
show global variables like "server_audit%";验证审核功能是否已启用:
Show global status like 'server_audit%';修改文件
/etc/rsyslog.conf以启用通过 UDP 进行转发:*.* @@<bindplane-agent-ip>:<bindplane-agent-port>- 将
<bindplane-agent-ip>和<bindplane-agent-port>替换为您的 Bindplane 代理配置。
- 将
重启 MySQL 服务:
/etc/init.d/mysqld restart
UDM 映射表
| 日志字段 | UDM 映射 | 逻辑 |
|---|---|---|
| 操作 | read_only_udm.metadata.event_type | 如果值为 Created,则为 FILE_CREATION;如果值为 Deleted,则为 FILE_DELETION;否则为无变化。 |
| 数据库 | read_only_udm.target.resource.parent | |
| db_hostname | read_only_udm.target.hostname | |
| db_user | read_only_udm.target.user.userid | |
| 说明 | read_only_udm.security_result.description | |
| error_details | 这是一个临时变量,请忽略它 | |
| error_level | read_only_udm.security_result.severity | 如果值为 error,则为 ERROR;如果值为 warning,则为 MEDIUM;如果值为 note,则为 INFORMATIONAL;否则不进行任何更改。 |
| error_message | read_only_udm.security_result.summary | |
| file_path | read_only_udm.target.file.full_path | |
| file_size | read_only_udm.target.file.size | |
| 主机名 | read_only_udm.principal.hostname | |
| inner_message | read_only_udm.security_result.description | |
| 摘要 | read_only_udm.metadata.product_event_type | |
| 表 | read_only_udm.target.resource.name | |
| table_not_found | 这是一个临时变量,请忽略它 | |
| 时间戳 | read_only_udm.metadata.event_timestamp | |
| read_only_udm.extensions.auth.type | 静态价值 - MACHINE |
|
| read_only_udm.metadata.event_type | 静态值 - USER_LOGIN、GENERIC_EVENT、STATUS_UPDATE、FILE_CREATION、FILE_DELETION |
|
| read_only_udm.metadata.log_type | 静态价值 - MYSQL |
|
| read_only_udm.metadata.product_name | 静态价值 - MySQL |
|
| read_only_udm.metadata.vendor_name | 静态价值 - Oracle Corporation |
|
| read_only_udm.security_result.action | 静态价值 - BLOCK |
|
| read_only_udm.target.resource.resource_type | 静态值 - DATABASE、TABLE |
|
properties.event_time |
event.idm.read_only_udm.metadata.event_timestamp |
从变更日志映射 |
properties.ip |
event.idm.read_only_udm.principal.ip和event.idm.read_only_udm.principal.asset.ip之间 |
从变更日志映射 |
properties.user |
event.idm.read_only_udm.principal.user.userid |
从变更日志映射 |
properties.error_code |
event.idm.read_only_udm.security_result.description |
从变更日志映射 |
properties.event_subclass |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
properties.is_aad_auth |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
category |
event.idm.read_only_udm.metadata.product_event_type |
从变更日志映射 |
ServerType |
event.idm.read_only_udm.target.application |
从变更日志映射 |
target_app |
event.idm.read_only_udm.target.application |
从变更日志映射 |
properties.start_time |
event.idm.read_only_udm.metadata.event_timestamp |
从变更日志映射 |
ts |
event.idm.read_only_udm.metadata.event_timestamp |
从变更日志映射 |
time |
event.idm.read_only_udm.metadata.collected_timestamp |
从变更日志映射 |
properties.server_id |
event.idm.read_only_udm.target.asset.asset_id |
从变更日志映射 |
properties.thread_id |
event.idm.read_only_udm.principal.process.pid |
从变更日志映射 |
user_id |
event.idm.read_only_udm.principal.user.userid |
从变更日志映射 |
p_host |
event.idm.read_only_udm.principal.hostname |
从变更日志映射 |
p_host |
event.idm.read_only_udm.principal.asset.hostname |
从变更日志映射 |
properties.db |
event.idm.read_only_udm.target.resource.name |
从变更日志映射 |
resourceId |
event.idm.read_only_udm.target.resource.product_object_id |
从变更日志映射 |
operationName |
event.idm.read_only_udm.metadata.description |
从变更日志映射 |
location |
event.idm.read_only_udm.target.location.name |
从变更日志映射 |
properties.host |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
properties.last_insert_id |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
properties.insert_id |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
properties.sql_text |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
properties.rows_examined |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
properties.rows_sent |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
properties.lock_time |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
properties.query_time |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
properties.replication_set_role |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
properties.event_class |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
csv_principal_hostname |
event.idm.read_only_udm.principal.ip和event.idm.read_only_udm.principal.asset.ip之间 |
从变更日志映射 |
csv_hostname |
event.idm.read_only_udm.target.hostname和event.idm.read_only_udm.target.asset.hostname之间 |
从变更日志映射 |
csv_principal_hostname |
event.idm.read_only_udm.principal.hostname和event.idm.read_only_udm.principal.asset.hostname之间 |
从变更日志映射 |
ts |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
csv_query_id |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
csv_mysql |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
account_host |
event.idm.read_only_udm.principal.resource.attribute.labels |
从变更日志映射 |
login_proxy |
event.idm.read_only_udm.principal.resource.attribute.labels |
从变更日志映射 |
login_os |
event.idm.read_only_udm.principal.resource.attribute.labels |
从变更日志映射 |
arg |
event.idm.read_only_udm.principal.resource.attribute.labels |
从变更日志映射 |
startup_data_server_id |
event.idm.read_only_udm.principal.resource.product_object_id |
从变更日志映射 |
startup_data_os_version |
event.idm.read_only_udm.principal.platform_version |
从变更日志映射 |
startup_data_mysql_version |
event.idm.read_only_udm.metadata.product_version |
从变更日志映射 |
arg |
event.idm.read_only_udm.principal.process.command_line |
从变更日志映射 |
csv_mysql_sql_query |
event.idm.read_only_udm.target.resource.attribute.labels |
从变更日志映射 |
hostname |
event.idm.read_only_udm.intermediary.hostname和event.idm.read_only_udm.intermediary.asset.hostname之间 |
从变更日志映射 |
id |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
login.proxy |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
connection_data.connection_type |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
connection_data.status |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
login.os |
event.idm.read_only_udm.principal.platform_version |
从变更日志映射 |
account.host |
event.idm.read_only_udm.target.hostname和event.idm.read_only_udm.target.asset.hostname之间 |
从变更日志映射 |
connection_data.db |
event.idm.read_only_udm.target.application |
从变更日志映射 |
mysql_description |
event.idm.read_only_udm.metadata.description |
从变更日志映射 |
mysql_errno |
event.idm.read_only_udm.metadata.product_log_id |
从变更日志映射 |
mysql_version |
event.idm.read_only_udm.metadata.product_version |
从变更日志映射 |
process_path |
event.idm.read_only_udm.principal.process.file.full_path |
从变更日志映射 |
mysql_port |
event.idm.read_only_udm.principal.port |
从变更日志映射 |
status |
event.idm.read_only_udm.security_result.summary |
从变更日志映射 |
error_level |
event.idm.read_only_udm.security_result.severity_details |
从变更日志映射 |
mysql_thread_id |
event.idm.read_only_udm.network.session_id |
从变更日志映射 |
mysql_socket |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
log_level |
event.idm.read_only_udm.additional.fields |
从变更日志映射 |
mysql_timestamp |
event.idm.read_only_udm.metadata.event_timestamp |
从变更日志映射 |
event_date |
event.idm.read_only_udm.metadata.event_timestamp |
从变更日志映射 |
event_time |
event.idm.read_only_udm.metadata.event_timestamp |
从变更日志映射 |
csv_timestamp |
event.idm.read_only_udm.metadata.event_timestamp |
从变更日志映射 |
mysql_action |
event.idm.read_only_udm.metadata.product_event_type |
从变更日志映射 |
log_category |
event.idm.read_only_udm.metadata.product_event_type |
从变更日志映射 |
csv_mysql_action |
event.idm.read_only_udm.metadata.product_event_type |
从变更日志映射 |
csv_mysql_connection_type |
event.idm.read_only_udm.metadata.product_event_type |
从变更日志映射 |
event_message |
event.idm.read_only_udm.metadata.description |
从变更日志映射 |
resolution_error |
event.idm.read_only_udm.metadata.description |
从变更日志映射 |
component |
event.idm.read_only_udm.principal.application |
从变更日志映射 |
mysql_hostname |
event.idm.read_only_udm.principal.ip和event.idm.read_only_udm.principal.asset.ip之间 |
从变更日志映射 |
csv_hostname_ip |
event.idm.read_only_udm.principal.ip和event.idm.read_only_udm.principal.asset.ip之间 |
从变更日志映射 |
mysql_username |
event.idm.read_only_udm.principal.user.userid |
从变更日志映射 |
csv_username |
event.idm.read_only_udm.principal.user.userid |
从变更日志映射 |
csv_target_hostname |
event.idm.read_only_udm.target.hostname和event.idm.read_only_udm.target.asset.hostname之间 |
从变更日志映射 |
csv_database_name |
event.idm.read_only_udm.target.resource.name |
从变更日志映射 |
mysql_sql_query |
event.idm.read_only_udm.target.resource.attribute.labels |
从变更日志映射 |
csv_connection_id |
event.idm.read_only_udm.network.session_id |
从变更日志映射 |
mysql_message_id |
event.idm.read_only_udm.security_result.rule_id |
从变更日志映射 |
target_mysql_hostname |
event.idm.read_only_udm.target.hostname和event.idm.read_only_udm.target.asset.hostname之间 |
从变更日志映射 |
csv_mysql_connection_type |
event.idm.read_only_udm.security_result.detection_fields |
从变更日志映射 |
login.ip |
event.idm.read_only_udm.principal.ip |
从变更日志映射 |
login.ip |
event.idm.read_only_udm.principal.asset.ip |
从变更日志映射 |
login.user |
event.idm.read_only_udm.principal.user.userid |
从变更日志映射 |
account.user |
event.idm.read_only_udm.target.user.userid |
从变更日志映射 |
inter_host |
event.idm.read_only_udm.intermediary.hostname |
从变更日志映射 |
target_host |
event.idm.read_only_udm.target.hostname |
从变更日志映射 |
target_host |
event.idm.read_only_udm.target.asset.hostname |
从变更日志映射 |
target_ip |
event.idm.read_only_udm.target.ip |
从变更日志映射 |
target_ip |
event.idm.read_only_udm.target.asset.ip |
从变更日志映射 |
connection_id |
event.idm.read_only_udm.network.session_id |
从变更日志映射 |
general_data.command |
event.idm.read_only_udm.target.process.command_line |
从变更日志映射 |
general_data.query |
event.idm.read_only_udm.security_result.summary |
从变更日志映射 |
connection_data.connection_type |
event.idm.read_only_udm.network.ip_protocol |
从变更日志映射 |
general_data.sql_command |
event.idm.read_only_udm.security_result.detection_fields |
从变更日志映射 |
event_data |
event.idm.read_only_udm.security_result.detection_fields |
从变更日志映射 |
general_data.status |
event.idm.read_only_udm.security_result.detection_fields |
从变更日志映射 |
class |
event.idm.read_only_udm.security_result.detection_fields |
从变更日志映射 |
Status |
event.idm.read_only_udm.security_result.detection_fields |
从变更日志映射 |
sql_query |
event.idm.read_only_udm.target.resource.attribute.labels |
从变更日志映射 |
value |
event.idm.read_only_udm.target.resource.attribute.labels |
从变更日志映射 |
num |
event.idm.read_only_udm.target.resource.attribute.labels |
从变更日志映射 |
ns |
event.idm.read_only_udm.target.resource.attribute.labels |
从变更日志映射 |
itemid |
event.idm.read_only_udm.target.resource.attribute.labels |
从变更日志映射 |
value_min |
event.idm.read_only_udm.target.resource.attribute.labels |
从变更日志映射 |
value_avg |
event.idm.read_only_udm.target.resource.attribute.labels |
从变更日志映射 |
value_max |
event.idm.read_only_udm.target.resource.attribute.labels |
从变更日志映射 |
query_id |
event.idm.read_only_udm.target.resource.attribute.labels |
从变更日志映射 |
clock |
event.idm.read_only_udm.metadata.event_timestamp |
从变更日志映射 |
path |
principal.file.full_path |
从变更日志映射 |
logtype |
metadata.product_event_type |
从变更日志映射 |