Description
Choose how long ApsaraDB RDS keeps collected SQL statements for troubleshooting and audits. Database backups have a separate retention policy.
Potential impact
If SQL collection is off or the records expire before an issue is discovered, you may lose the query history needed to investigate it.
Remediation
Set sql_collector_status = "Enabled", then choose a supported sql_collector_config_value in days. If your policy requires at least 180 days, options include 180 and 365. Restrict access to the SQL records and review storage costs.
Examples
Both MySQL configurations enable SQL collection. The second extends record retention from 30 to 180 days.
Before
hcl
resource "alicloud_db_instance" "default" {
engine = "MySQL"
engine_version = "5.6"
instance_type = "rds.mysql.t1.small"
instance_storage = "10"
sql_collector_status = "Enabled"
sql_collector_config_value = 30
}
After
hcl
resource "alicloud_db_instance" "default" {
engine = "MySQL"
engine_version = "5.6"
instance_type = "rds.mysql.t1.small"
instance_storage = "10"
sql_collector_status = "Enabled"
sql_collector_config_value = 180
}