This topic describes how to use the SQL Audit feature on an ApsaraDB RDS for PostgreSQL instance. This feature allows you to audit the executed SQL statements on a regular basis and view the details about the executed SQL statements. After you enable the SQL Audit feature, the performance of the RDS instance is not affected.
Precautions
- You cannot view the SQL statements that are executed before the SQL Audit feature is enabled.
- After you enable the SQL Audit feature, the performance of the RDS instance is not affected.
- The retention period of SQL audit logs is 30 days.
- The exported SQL audit log files can be retained for two days. After the retention period elapses, the system deletes the SQL audit log files.
- The maximum size per SQL statement is 8,000 bytes. If the size of an SQL statement exceeds 8,000 bytes, the excessive bytes cannot be logged.
Billing
- The SQL Audit feature is disabled by default. After you enable the SQL Audit feature,
you are charged per hour for using this feature on the RDS instance.
The fee charged per hour varies in different Alibaba Cloud regions:
- USD 0.15/GB-hour: China (Hong Kong), US (Silicon Valley), and US (Virginia).
- USD 0.18/GB-hour: Singapore (Singapore), Japan (Tokyo), Germany (Frankfurt), UAE (Dubai), Australia (Sydney), Malaysia (Kuala Lumpur), India (Mumbai), Indonesia (Jakarta), and UK (London).
- USD 0.12/GB-hour: all regions except the preceding regions.
- After the SQL Explorer and Audit feature is enabled, ApsaraDB RDS stops billing the Use the SQL Explorer and Audit feature on an ApsaraDB RDS for PostgreSQL instance feature. The pricing of the SQL Explorer and Audit feature is based on the pricing of Database Autonomy Service (DAS) Professional Edition. For more information, see Pricing of DAS Professional Edition.
Enable the SQL Explorer and Audit feature
The SQL Explorer and Audit feature is supported for ApsaraDB RDS for PostgreSQL instances. The SQL detail search item is enhanced, and items such as Full SQL analysis, SQL insight-comparison view, and SQL insight-source analysis are added. You can view the item and billing differences between the SQL Audit feature and the SQL Explorer and Audit feature in the dialog box that appears when you click the SQL Audit tab. For more information, see Use the SQL Explorer and Audit feature on an ApsaraDB RDS for PostgreSQL instance.
Enable the SQL Audit feature
If you do not want to enable the SQL Explorer and Audit feature and want to use the SQL Audit feature, perform the following operations:
After the SQL Audit feature is enabled, you can query SQL statements based on the specified search criteria, such as the time range, databases, users, and keywords.
Disable SQL Audit
If you no longer use the SQL Audit feature, you can disable the feature to reduce costs.