• Data Warehouse Service

  1. Help Center
  2. Data Warehouse Service
  3. Developer Guide
  4. Database Security Management
  5. Viewing the Auditing Information

Viewing the Auditing Information


When the DWS cluster is abnormal or when you manage services, you can query the audit information to locate the fault cause or historical operations record as needed.


  • You must have the audit permission. If rights are not separated, you can use the administrator user created during cluster creation. If rights are separated, you need to use the audit administrator.
  • The required audit items have been enabled. For details about how to enable them, see Configuring the Database Audit Log.


  1. Connect to the database.
  2. Run the following command to query the audit information:

    SELECT * FROM pg_query_audit(starttime, endtime);

    starttime indicates the start time when the query starts and endtime indicates the end time when the query ends. Single quotation marks (' ') must be used to enclose the time.

    For example, run the following command:

    SELECT * FROM pg_query_audit('07/30/2015 08:00:00','07/30/2018 08:00:00');

  3. View the query result.

    The following result is displayed:

    time          |     type      | result | username |    database    | client_conninfo |  object_name   |                          detail_info                | node_name |            thread_id            | local_port | remote_port
    07/26/2017 08:28:00 UTC | login_success | ok     | dbadmin | postgres       | gs_clean@::1    | postgres       | login db(postgres) success,the current user is:dbadmin       | cn_5003   | 139808902997776@490233835920483 | 8000       | 55805

    The preceding record indicates that user dbadmin has connected to database postgres.