All Products
Search
Document Center

ApsaraDB RDS:Manage logs

Last Updated:May 08, 2024

This topic describes how to view the error logs of an ApsaraDB RDS for SQL Server instance in the ApsaraDB RDS console or by using SQL statements. You can use the error logs to identify issues. You can also clean up the error logs of an RDS instance to release the disk space in the ApsaraDB RDS console or by calling an API operation. In addition, if a primary/secondary switchover occurs, you can monitor the switchover status by viewing the primary/secondary switchover logs of an RDS instance in the ApsaraDB RDS console.

View error logs

View error logs in the ApsaraDB RDS console

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
  2. In the left-side navigation pane, click Logs.

  3. On the Error Logs tab, select a time range to search for error logs.

    Tab

    Description

    Error Logs

    Provides logs on events that occurred over the last month. The events include custom events and specific system events.

View error logs by using SQL statements

  • If your RDS instance runs SQL Server 2016 or earlier, run the sp_rds_read_error_logs stored procedure to obtain error logs.

    -- Example 1: Return all error logs
    EXEC sp_rds_read_error_logs
    
    -- Example 2: Begin the search from Row 0 of the error log and return the first row that contains the error keyword.
    EXEC sp_rds_read_error_logs 0,1 ,'error'
  • If your RDS instance runs SQL Server 2017 or later, run the sp_readerrorlog stored procedure to obtain error logs.

    EXEC sp_readerrorlog

Clean up error logs

You can clean up the error logs of an RDS instance to release the disk space in the ApsaraDB RDS console or by calling an API operation. For error logs that have been uploaded to an Object Storage Service (OSS) bucket, you can still view the error logs in the ApsaraDB RDS console, which are not affected by the cleanup operation. For more information, see ModifyDBInstanceConfig.

Note

RDS instances that run SQL Server 2008 R2 do not support the cleanup operation.

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
  2. In the left-side navigation pane, click Logs.

  3. On the Error Logs tab, click Clean Disk Space Occupied by Error Logs.

  4. Click OK.

    You can view disk usage on the Monitoring and Alerts page. For more information, see View storage usage.

View primary/secondary switchover logs

Note

You can view primary/secondary switchover logs only when the primary RDS instance runs SQL Server 2008 R2 with local disks.

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
  2. In the left-side navigation pane, click Service Availability.

  3. In the Primary/Secondary Switching Logs section of the page that appears, select a time range and view the primary/secondary switchover logs that are generated over the selected time range.

    image.png

References