LoginSignup
5
1

More than 3 years have passed since last update.

RDS for MySQL の Audit Log を取得する

Posted at

はじめに

RDS for MySQL の Audit ログを取得する方法を紹介します。RDS でどんなユーザーがいつログインして、どのようなクエリーを発行したのか、といったことを CloudWatch Logs に出力が出来ます。監査目的に非常に重要な重要なので、必要なセキュリティ要件が有る場合はぜひ取得するのが良いです。

備忘録的に手順を紹介します。

Option group 作成

まず、Option group で、Audit Log 取得用の Plugin を有効にします。

Create group

1611996208250.png

Create

1611996400488.png

Add option

1611996456153.png

Option name で、MARIADB_AUDIT_PLUGIN を選択して、どのような Audit Log を有効にするか指定します。

SERVER_AUDIT_EVENTS

CONNECT,QUERY,TABLE,QUERY_DDL,QUERY_DML,QUERY_DCL

1611996579982.png

RDS 作成

Create database

1611996791708.png

作成した Option group を指定

1611996924397.png

Log exports も有効化

1611996942136.png

Create を押すと、作成される

1611997433685.png

Cloud Watch Logs

Log groups が自動的に作成される

1611997274955.png

確認

接続

[opc@onprem-server01 ~]$ mysql -u admin -h audit-test01.comulzzpkhpz.ap-northeast-1.rds.amazonaws.com -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.31-log Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

コマンドを実行すると、Log group が新たに生成される

1611998267730.png

こんな感じに適当に database や table を作成

create database sugitest;

use sugitest;

CREATE TABLE sample(
 id INT(11) NOT NULL AUTO_INCREMENT,
 value INT(5) NOT NULL DEFAULT 0,
 PRIMARY KEY (id)
);

INSERT INTO sample(value) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);

実行したクエリーが、CloudWatch Logs 上でも確認できます。

1612005720127.png

参考URL

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1