收集 MySQL 記錄
本文說明如何使用 Bindplane 代理程式,將 MySQL 記錄擷取至 Google Security Operations。
MySQL 是關聯式資料庫管理系統,可為驗證事件、查詢執行、資料庫作業和稽核追蹤記錄項目產生系統記錄訊息。剖析器會從 Syslog 格式的稽核記錄中擷取欄位,並對應至統合資料模型 (UDM)。
事前準備
請確認您已完成下列事前準備事項:
- Google SecOps 執行個體
- Windows Server 2016 以上版本,或搭載
systemd的 Linux 主機 - Bindplane 代理程式與 MySQL 伺服器之間的網路連線
- 如果透過 Proxy 執行,請確保防火牆通訊埠已根據 Bindplane 代理程式需求開啟
- 具有 root 或 sudo 權限的 MySQL 主機 SSH 存取權
取得 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 安裝
- 開啟具有根層級或 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 代理程式,擷取系統記錄檔並傳送至 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是標準的系統記錄通訊埠 (在 Linux 上需要根層級權限;非根層級權限請使用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 Collector。
- 按一下滑鼠右鍵,然後選取「重新啟動」。
確認服務正在執行:
sc query observiq-otel-collector檢查記錄中是否有錯誤:
type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
- 按下
在 MySQL 中設定系統記錄檔
- 使用 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 |
從變更記錄對應 |
變更記錄
還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求答案。