This topic describes how to query error logs, slow query logs, and primary/secondary switching logs of an ApsaraDB RDS for PostgreSQL instance by using the ApsaraDB for RDS console or SQL statements.

Precautions

Primary/secondary switching logs are not available in the Basic Edition.

Procedure

  1. Log on to the ApsaraDB for RDS console.
  2. In the top navigation bar, select the region where the target RDS instance resides.
  3. Find the target RDS instance and click its ID.
  4. In the left-side navigation pane, click Logs.
  5. On the Logs page, click the Error Logs, Slow Query Logs, or Primary/Secondary Switching Logs tab, select a time range, and click Search.
    Item Description
    Error logs Record database running errors that occurred in the last month.
    Slow query logs Record SQL statements that take more than one second to execute in the last month. Duplicated SQL statements are removed.
    Primary/secondary switching logs Record switchovers between the primary and secondary instances in the last month. Primary/secondary switching logs are available only for RDS instances that are not in the Basic Edition.
    Note
    • If your RDS instance resides in the China (Zhangjiakou-Beijing Winter Olympics) region, the system only retains error logs and slow query logs generated in the last nine days.
    • The system collects logs from databases and saves the CSV log files to a log server. If you want to adjust the maximum number of retained log files, configure the rds_max_log_files parameter for the RDS instance. If more log files are retained, you can query logs in a longer time range. However, the log files occupy larger storage space.

Related operations

Operation Description
DescribeSlowLogs Queries the list of slow query logs.
DescribeSlowLogRecords Queries details about slow query logs.
DescribeErrorLogs Queries error logs.
DescribeBinlogFiles Queries binary logs.
DescribeSQLLogRecords Queries details about SQL audit logs.
DescribeSQLLogFiles Queries the list of SQL audit logs.