MySQL ログを収集する
このドキュメントでは、Bindplane エージェントを使用して MySQL ログを Google Security Operations に取り込む方法について説明します。
MySQL は、認証イベント、クエリ実行、データベース オペレーション、監査証跡エントリの syslog メッセージを生成するリレーショナル データベース管理システムです。パーサーは、Syslog 形式の監査ログからフィールドを抽出し、Unified Data Model(UDM)にマッピングします。
始める前に
次の前提条件を満たしていることを確認してください。
- Google SecOps インスタンス
- Windows Server 2016 以降、または
systemdを使用する Linux ホスト - Bindplane エージェントと MySQL サーバー間のネットワーク接続
- プロキシの背後で実行している場合は、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 のインストール
- 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 エージェントのインストール ガイドをご覧ください。
syslog を取り込んで Google SecOps に送信するように Bindplane エージェントを構成する
構成ファイルを探す
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: リージョナル エンドポイント URL:- 米国:
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 で syslog を構成する
- SSH を使用して MySQL ホストにログインします。
MySQL データベースに接続します。
mysql -u root -pserver_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 | |
| hostname | 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 | これは一時変数です。無視してください | |
| timestamp | 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 のプロフェッショナルから回答を得ることができます。