Облачная платформаAdvanced

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 ensure performance, audit logs use the Coordinated Universal Time (UTC) and are not affected by time zone settings.
  • When you enable SQL audit, the system automatically installs the pgAudit extension for a specific database. If you want to audit another database after SQL audit is enabled, manually install pgAudit for this database. For details, see pgAudit.
  • After SQL audit is enabled, READ, WRITE, and DDL SQL statements are logged by default. To adjust the audit scope, change the value of pgaudit.log on the Parameters page. For details, see Modifying Parameters of an RDS for PostgreSQL Instance.

Supported Database Versions

Only the following versions support SQL audit. If your DB engine version is too low, upgrade it to the latest version by referring to Upgrading the Minor Version or Upgrading the Major Version of a DB Instance on the Console.

  • Latest minor versions of RDS for PostgreSQL 12 and 13
  • All versions of RDS for PostgreSQL 14 and above

Performance

The pgAudit impact on database performance depends on how many audit logs there are and how often they are generated. More audit logs mean more impact on the database performance. pgAudit can decrease the database performance by about 20%. You need to configure parameters for pgAudit based on your workloads to achieve a balance between audit requirements and database performance.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner of the page and choose Database > Relational Database Service.
  3. On the Instances page, click the target instance name to go to the Basic Information page.
  4. In the navigation pane, choose Logs. On the SQL Audit Logs tab 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 3,660 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.

    Notice

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