Updated on 2024-07-18 GMT+08:00

Enabling SQL Audit

Scenarios

After SQL audit is enabled for RDS for PostgreSQL DB instances, the system records SQL operations and uploads logs every half an hour or when the size of a single record reaches 100 MB. The generated audit logs are stored in OBS.

Precautions

  • SQL audit is disabled for DB instances by default because enabling it increases database loads.
  • To enable SQL audit, you need to install the pgAudit extension first. For details, see pgAudit.

Constraints

Only the following versions support SQL audit.
  • Latest minor versions of RDS for PostgreSQL 12 and 13
  • All versions of RDS for PostgreSQL 14 and above

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner of the page and choose Databases > Relational Database Service.
  3. On the Instances page, click the DB instance name.
  4. In the navigation pane, choose SQL Audits. On the displayed page, click Set SQL Audit.
  5. In the displayed dialog box, set the number of days for storing SQL audit logs and click OK.

    Audit logs can be retained from 1 to 732 days and are retained for 7 days by default.

  6. To disable SQL audit, toggle off the Audit Logging switch, select the confirmation check box, and click OK.

    After SQL audit is disabled, all audit logs will be deleted immediately and cannot be recovered. Exercise caution when performing this operation.