Skip to content

Monitor Amazon RDS for PostgreSQL and Aurora PostgreSQL

This guide walks you through monitoring Amazon RDS for PostgreSQL databases and an Aurora PostgreSQL cluster with QubeSight installed from AWS Marketplace, entirely in the AWS console: install QubeSight, turn on pgaudit, export the PostgreSQL log to CloudWatch Logs, connect QubeSight to the log groups and verify that every statement arrives. It also covers the path without CloudWatch Logs (Aurora Database Activity Streams) and what is and is not possible for RDS for PostgreSQL.

Enterprise

The CloudWatch Logs and Kinesis readers are Enterprise features. A Marketplace installation includes an optional 30-day Enterprise evaluation, so you can follow this guide on a new installation before you have a licence.

The steps and pictures were recorded with QubeSight 2.0.110 in us-east-1 on RDS for PostgreSQL 16.15 (db.t4g.medium) and Aurora PostgreSQL 16.15 (db.r7g.large). Account IDs, addresses and key IDs in the pictures are examples.

Which path to use

Database Recommended path Without CloudWatch Logs
RDS for PostgreSQL pgaudit → PostgreSQL log → CloudWatch Logs → QubeSight reads the log group directly Not available. Database Activity Streams exist for RDS only for Oracle and SQL Server; see RDS for PostgreSQL without CloudWatch Logs.
Aurora PostgreSQL pgaudit → PostgreSQL log → CloudWatch Logs, the same as RDS Database Activity Streams → Kinesis → QubeSight (r-class or other provisioned instances; not Aurora Serverless)

If you already export the PostgreSQL log of your databases to CloudWatch Logs, you only need step 2 (if pgaudit is not on yet) and steps 4 and 5.

How it works

RDS for PostgreSQL / Aurora PostgreSQL
  pgaudit + log_connections + log_disconnections
        │  (PostgreSQL log, RDS log_line_prefix %t:%r:%u@%d:[%p]:)
        ▼
CloudWatch Logs  /aws/rds/instance/<db>/postgresql
                 /aws/rds/cluster/<cluster>/postgresql
        │  FilterLogEvents every 15 s (instance role, read-only)
        ▼
QubeSight worker → one event per audit line, login, failed login, logout and error

QubeSight reads the log groups with the EC2 instance role; it creates nothing in your AWS account, needs no subscription filter and no Kinesis stream. Details of the reader (cursor, overlap, quota) are in AWS CloudWatch Logs.

Step 1: install QubeSight from AWS Marketplace

The full walkthrough with every parameter is in AWS (AMI and CloudFormation). In short:

  1. In the AWS Marketplace console open the QubeSight listing and choose View purchase options. Subscribing to the bring-your-own-licence offer costs nothing; your account owner accepts the terms once per account.

    AWS Marketplace listing of QubeSight in the AWS console with the View purchase options button.

  2. After the subscription is active the page shows You've already accepted this offer. Choose Launch your software.

    Purchase options page showing the accepted offer and the Launch your software button.

  3. Choose the CloudFormation template QubeSight single instance (CloudFormation), the version and your Region, then Launch with CloudFormation.

    Launch page: CloudFormation template single instance, version 2.0.110, Region US East (N. Virginia), Launch with CloudFormation.

  4. On Specify stack details enter a stack name, the VPC and Subnet where the databases live (or one that can reach CloudWatch Logs over HTTPS), your Admin access CIDR and, as Log source CIDR, the CIDR of the VPC. Leave the CloudWatch Logs field empty for now; you fill it in step 4. Keep the defaults on the next page, tick the IAM acknowledgement and choose Submit.

    Specify stack details: VPC, subnet, admin access CIDR, log source CIDR and key pair.

  5. Wait for CREATE_COMPLETE (about 15 to 20 minutes; the stack completes only after QubeSight is installed and answers). The Outputs tab shows the web address and the link to the Secrets Manager secret with the initial admin password.

    Stack Outputs: admin secret ARN and console link, data volume, ingest endpoints, instance.

  6. Open the web address, sign in as admin with the password from the secret and set a new password when asked.

    QubeSight sign-in page explaining that the first passwords are in AWS Secrets Manager.

    Forced password change at the first sign-in.

  7. Platform → Settings → License shows Enterprise, licence provider AWS Marketplace with the Trial badge and the days remaining. Upload your Enterprise licence here when you have it.

    Settings, License: Enterprise, AWS Marketplace, Trial, 30 days remaining.

Step 2: turn on pgaudit

PostgreSQL writes nothing about individual statements by default. pgaudit adds one AUDIT: line per statement to the PostgreSQL log, and log_connections / log_disconnections add logins, failed logins and logouts. You set them in a custom parameter group: the default groups cannot be changed.

RDS for PostgreSQL: DB parameter group

  1. In the RDS console open Parameter groups → Create parameter group. Engine type PostgreSQL, family matching your engine (for example postgres16), type DB Parameter Group. Give it a name and description and choose Create.

    Create parameter group: PostgreSQL, family postgres16.

  2. Open the group, choose Edit and set:

    Parameter Value Why
    shared_preload_libraries add pgaudit to the existing list, for example pg_stat_statements,pg_tle,pgaudit Loads pgaudit. Static: needs a reboot of instances that already use the group.
    pgaudit.log ddl,role,write,read Statement classes to audit (see the table below).
    pgaudit.role rds_pgaudit Optional; needed only for object-level auditing (see below).
    log_connections 1 Successful logins (and the client address).
    log_disconnections 1 Logouts with the session duration.

    Leave log_line_prefix at the RDS default %t:%r:%u@%d:[%p]:; QubeSight relies on it to read the user, database and client.

    Editing shared_preload_libraries: pg_stat_statements,pg_tle,pgaudit.

    Editing pgaudit.log with the allowed values listed above the field: ddl,role,write,read.

    log_connections and log_disconnections set to 1.

  3. Choose Save changes.

What to put in pgaudit.log. The allowed values are shown above the field:

Value Audits Typical choice
read SELECT, COPY … TO Yes, if you must show who read personal or card data
write INSERT, UPDATE, DELETE, TRUNCATE, COPY … FROM Yes
ddl CREATE, ALTER, DROP of objects Yes
role GRANT, REVOKE, CREATE/ALTER/DROP ROLE Yes
function, misc Function calls and DO blocks; SET, VACUUM, CHECKPOINT, DISCARD … Only when an audit requires them; misc is noisy
all Everything above Simplest, but the most volume

ddl,role,write,read records every data access and change while leaving out the high-volume housekeeping classes. Choose all if your audit asks for every statement. Passwords in CREATE ROLE … PASSWORD are written as <REDACTED> by pgaudit.

Aurora PostgreSQL: DB cluster parameter group

The same settings go into a DB cluster parameter group (engine type Aurora PostgreSQL, family aurora-postgresql16, type DB Cluster Parameter Group). On Aurora, shared_preload_libraries lists pg_stat_statements by default; add pgaudit.

Create parameter group: Aurora PostgreSQL, family aurora-postgresql16, type DB Cluster Parameter Group.

Attach the group

  • New database: choose the group under Additional configuration → Database options (for Aurora: DB cluster parameter group).

    Create database, Additional configuration: initial database name and DB parameter group qsrds-pg16-audit; Log exports above.

  • Existing database: Modify → DB parameter group (Aurora: modify the cluster → DB cluster parameter group), apply, then reboot the instance (Aurora: the writer and readers) once, because shared_preload_libraries is static. Plan the reboot in a maintenance window.

Create the extension and the audit role

Connect once as the master user to each database you audit and run:

CREATE EXTENSION IF NOT EXISTS pgaudit;
-- Only if you use object-level auditing (pgaudit.role = rds_pgaudit):
CREATE ROLE rds_pgaudit;

Check the result:

SHOW shared_preload_libraries;   -- contains pgaudit
SHOW pgaudit.log;                -- ddl,role,write,read

Object-level auditing (optional). To audit only certain tables (for example only SELECT on customers) instead of a whole class, keep pgaudit.role = rds_pgaudit and grant the audited privileges to that role: GRANT SELECT ON customers TO rds_pgaudit;. Object audit lines are written as AUDIT: OBJECT,…; QubeSight reads both session and object lines.

Step 3: export the PostgreSQL log to CloudWatch Logs

RDS for PostgreSQL

  1. Select the database and choose Modify.
  2. Under Additional monitoring settings → Log exports tick PostgreSQL log.

    Modify DB instance: Log exports with PostgreSQL log ticked; DB parameter group qsrds-pg16-audit below.

  3. Choose Continue, select Apply immediately and Modify DB instance. Turning on the export does not restart the database.

    Summary of modifications: Enable publish to CloudWatch Logs, PostgreSQL log, Apply immediately.

RDS creates the log group /aws/rds/instance/<db-identifier>/postgresql. In CloudWatch → Log groups, open it and search for AUDIT to see the pgaudit lines:

CloudWatch log events of /aws/rds/instance/qsrds-pg/postgresql, plain text view, AUDIT lines for CREATE EXTENSION, CREATE ROLE (password redacted), GRANT and CREATE TABLE.

Aurora PostgreSQL

On the cluster (create or Modify the cluster), tick PostgreSQL log under Log exports. The log group is /aws/rds/cluster/<cluster-identifier>/postgresql, with one log stream per instance.

Create database for Aurora PostgreSQL: Log exports PostgreSQL log ticked, DB cluster parameter group qsrds-aurora-pg16-audit.

CloudWatch log events of /aws/rds/cluster/qsrds-aurora/postgresql with pgaudit lines.

Log retention

New RDS log groups never expire. Set a retention on the log group (Actions → Edit retention setting, for example 7 or 14 days) after QubeSight reads it; QubeSight keeps its own copy. Keep the retention longer than the longest QubeSight downtime you want to bridge.

Step 4: give QubeSight read access to the log groups

QubeSight reads with the instance role of its EC2 instance. It needs logs:FilterLogEvents on the log groups and logs:DescribeLogGroups (names only) for the group picker. The QubeSight template adds exactly this when you fill in one parameter:

  1. In CloudFormation, select the QubeSight stack and choose Update stack → Make a direct update (or create a change set to preview), Use existing template, Next.
  2. In CloudWatch Logs log group ARNs to read enter the ARNs of the log groups, comma-separated, without spaces:

    arn:aws:logs:us-east-1:111122223333:log-group:/aws/rds/instance/qsrds-pg/postgresql,arn:aws:logs:us-east-1:111122223333:log-group:/aws/rds/cluster/qsrds-aurora/postgresql
    

    A trailing * covers several groups, for example arn:aws:logs:us-east-1:111122223333:log-group:/aws/rds/instance/*.

  3. Leave the other parameters on Use existing value, tick the IAM acknowledgement and Submit. Only the instance role changes; the instance is not replaced or restarted.

    Update stack review: CloudWatchLogGroupArns set to the two log group ARNs, all other parameters Use existing value.

The role then has the inline policy qubesight-cloudwatch-logs-read:

IAM role of the QubeSight instance, inline policy qubesight-cloudwatch-logs-read with logs:FilterLogEvents and logs:DescribeLogStreams on the two log groups.

If your company manages IAM separately, attach an equivalent policy to the instance role yourself:

{"Version": "2012-10-17", "Statement": [
  {"Effect": "Allow", "Action": ["logs:FilterLogEvents"],
   "Resource": ["arn:aws:logs:<region>:<account-id>:log-group:/aws/rds/instance/<db>/postgresql",
                "arn:aws:logs:<region>:<account-id>:log-group:/aws/rds/instance/<db>/postgresql:*",
                "arn:aws:logs:<region>:<account-id>:log-group:/aws/rds/cluster/<cluster>/postgresql",
                "arn:aws:logs:<region>:<account-id>:log-group:/aws/rds/cluster/<cluster>/postgresql:*"]},
  {"Effect": "Allow", "Action": "logs:DescribeLogGroups", "Resource": "*"}]}

For log groups in other AWS accounts, see the cross-account role in AWS CloudWatch Logs.

Step 5: add the log groups in QubeSight

  1. Open Data Sources → Stream Sources → AWS CloudWatch Logs and choose New integration.
  2. Enter an Integration Name (events are tagged cloudwatch:<name>) and the AWS Region of the databases. The form starts with eu-central-1; change it.
  3. Type /aws/rds/ as Prefix and choose List groups, tick the PostgreSQL groups, then clear the prefix again (a prefix makes QubeSight read every new group under it; with the least-privilege policy above it can read only the listed groups).
  4. First read goes back (min): how much history to read at the start, for example 60. 0 starts from the moment you save.
  5. Leave Role ARN, External ID and the access keys empty: the instance role is used. Choose Save, then Test.

    New CloudWatch Logs Integration: name aws-rds-postgres, region us-east-1, two log groups ticked, first read 60 minutes, overlap 300 s.

After about 15 to 60 seconds the card shows Access Verified, Events Received, Last Event and one row per log group with its cursor, lag, events, unrecognised lines (Queue), overlap re-reads, throttling and the reading node:

AWS CloudWatch Logs card: Access Verified, Reading the last round completed without errors, Events Received, quota 15/25 calls/s, per-log-group table for the Aurora and RDS groups.

Step 6: verify

Run a short, known workload (or wait for real traffic) and check that it appears in QubeSight. We used this script against each database: 1 setup session as the master user (CREATE EXTENSION, CREATE ROLE ×3, GRANT ×2), an application session with 6 DDL statements (CREATE TABLE with primary keys, ALTER TABLE, CREATE INDEX, DROP TABLE), 20 INSERT, 5 UPDATE, 3 DELETE, 10 reads of a customers table with e-mail and card columns, a GRANT SELECT to an analyst, 3 reads by the analyst, a REVOKE, a 20-million-row SELECT, 200 single-row inserts in one transaction, one INSERT … SELECT of 5,000 rows, one read refused after the REVOKE, and 5 failed logins.

Check Where in QubeSight Expected
Every pgaudit line is one event Reports → All Activity, filter Server Hostname = the DB identifier One row per AUDIT: line in CloudWatch. A CREATE TABLE with a primary key is 2 lines (table and index), a bigserial column adds the sequence.
Logins, logouts, failed logins Reports → Failed Login Attempts, Successful Logins One row each, with user, client address and database
Refused statements Reports → Errors and Failed Operations The ERROR: permission denied line, with the error text
Overview Activity Overview Events, users, databases and the command breakdown
One person's activity Dashboards → Mindmap Sessions, queries, failed logins and operation mix of that user
Alerts Assurance Center → Alerts & Notifications Privilege / account change for GRANT, REVOKE and CREATE/ALTER/DROP ROLE; Failed login burst for 5 or more failed logins of one user from one client within 10 minutes
Sensitive data Assurance Center → Sensitive Data The customers table classified (PII, payment card) from its column names

Reports, All Activity filtered on Server Hostname contains qsrds-pg.

Reports, Privilege Changes (DCL) filtered on the Aurora cluster: two GRANT by postgres, GRANT and REVOKE by the application user.

Reports, Failed Login Attempts: ten failed logins over both databases.

Activity Overview after the test workload on both databases.

Dashboards, Mindmap for the application user: session timeline with failed logins, sessions, sources, operation mix.

Alerts: privilege/account change per user and database, failed login burst.

Sensitive Data overview: the customers table detected as sensitive, operations and top accessors.

Counting it exactly. To prove completeness, count the lines in CloudWatch Logs for a time window (for example with aws logs filter-log-events --log-group-name … --start-time … --filter-pattern AUDIT) and compare with the number of report rows for that server and window. In our test both databases gave 261 audit lines, 5 sessions, 5 failed logins and 1 error each; QubeSight stored exactly these, with no duplicates, also after a worker restart in the middle of a second workload (60 statements per database, 60 stored).

Without CloudWatch Logs: Aurora Database Activity Streams

Aurora PostgreSQL can push every statement, login and failed login itself into an encrypted Amazon Kinesis stream (Database Activity Streams, DAS), independently of pgaudit and CloudWatch Logs. Use it when you do not want the audit trail in CloudWatch Logs or when DBAs must not be able to change auditing.

Requirements: a provisioned Aurora PostgreSQL cluster (memory-optimised or other non-burstable classes, for example db.r7g.large; not Aurora Serverless, not db.t*), a supported version (Aurora PostgreSQL 16.1 and later, 15.2 and later, and all 14 versions in the regions AWS lists) and a customer-managed KMS key.

  1. Create a KMS key. In Key Management Service → Customer managed keys → Create key: symmetric, encrypt and decrypt, an alias such as qubesight-das, default key policy.
  2. Start the activity stream. In RDS select the cluster, Actions → Start database activity stream, choose the KMS key, mode Asynchronous (the database never waits for the stream) and Immediately.

    Start database activity stream for the Aurora cluster: KMS key qubesight-das, Asynchronous, Immediately.

    After 10 to 20 minutes the status is started and AWS has created the Kinesis stream aws-rds-das-<cluster-resource-id>. Do not rename it: QubeSight derives the decryption context from the name.

  3. Grant QubeSight read and decrypt access. Update the QubeSight stack as in step 4 and fill Kinesis stream ARN to read and KMS key ARN of the activity stream. The template grants Kinesis read on that stream and kms:Decrypt restricted to RDS activity-stream data keys.

    Update stack review: ActivityStreamKmsKeyArn and KinesisStreamArn set, all other parameters Use existing value.

  4. Add the stream in QubeSight. Data Sources → Stream Sources → AWS Kinesis → New integration: name, region, Stream Name aws-rds-das-…, no keys. Save, then Test; the test decrypts one record to prove kms:Decrypt.

    AWS Kinesis card with the Database Activity Streams badge, Access Verified and the decrypting status line.

  5. Verify with the same workload as in step 6. Events from the activity stream are tagged kinesis:<name>; heartbeat records are counted, not stored.

    Reports, All Activity filtered on Database Name dasdb: failed logins from the activity stream with the verb AUTH FAILURE, sessions and statements.

In our test the activity stream delivered every statement of the workload exactly once (271 events: 6 DDL, 221 INSERT, 5 UPDATE, 3 DELETE, 15 SELECT, GRANT/REVOKE, BEGIN/COMMIT, 5 sessions with logout, 5 failed logins), with no duplicates. Compared with pgaudit, the activity stream also records statements that fail, with their SQL and SQLSTATE (for example 42501: permission denied for table customers), and records failed logins with the verb AUTH FAILURE and SQLSTATE 28P01.

The activity stream identifies the database by its AWS resource IDs: Server Hostname shows the instance resource ID (db-…) and Service Name the cluster resource ID (cluster-…), not the names you gave them. Use Database Name, the source tag kinesis:<name> or the resource IDs (shown in the RDS console under Configuration) to filter.

DAS and pgaudit together

An activity stream does not need pgaudit and does not change the PostgreSQL log. If you keep both the CloudWatch Logs integration and the activity stream for the same cluster, QubeSight stores each statement twice (once per source). Use one source per database, or keep the second one only during a migration.

RDS for PostgreSQL without CloudWatch Logs

For RDS for PostgreSQL there is no supported way to get the audit trail into QubeSight without CloudWatch Logs:

  • Database Activity Streams are available on RDS only for Oracle and SQL Server, not for RDS for PostgreSQL (or MySQL and MariaDB).
  • RDS for PostgreSQL has no syslog forwarding; log_destination only offers stderr, csvlog and jsonlog into the instance's own log files.
  • The log files can be downloaded through the RDS API (DescribeDBLogFiles, DownloadDBLogFilePortion), but they rotate and are kept only for rds.log_retention_period (3 days by default), and QubeSight does not read them. We do not recommend building on this for an audit trail.

If CloudWatch Logs is not allowed, the options are to move the database to Aurora PostgreSQL and use Database Activity Streams, or to forward the CloudWatch Logs group through a Kinesis subscription filter (CloudWatch Logs through Kinesis) if the concern is the read path rather than CloudWatch Logs itself.

Costs

AWS charges you; QubeSight itself adds no AWS fees.

Item What drives the cost
CloudWatch Logs ingestion and storage Volume of the PostgreSQL log (pgaudit lines are roughly 200–600 bytes each). Ingestion is charged per GB; storage per GB-month until the retention you set. read on busy tables is the largest share.
FilterLogEvents calls QubeSight reads each group every 15 seconds, capped at 60 % of the account's quota (25 calls/s in us-east-1).
Database Activity Streams The feature is free; you pay for the Kinesis stream (shard hours, typically several shards) and KMS requests (QubeSight caches data keys).
QubeSight instance The EC2 instance (default m7i.xlarge) and its EBS data volume.

A reduced pgaudit.log (for example without read) or object-level auditing of selected tables lowers the CloudWatch Logs volume.

Troubleshooting

Symptom Cause and action
No AUDIT: lines in CloudWatch pgaudit not in shared_preload_libraries of the attached group, the instance not rebooted after attaching it, CREATE EXTENSION pgaudit not run, or pgaudit.log empty. Check with SHOW shared_preload_libraries; SHOW pgaudit.log;.
The log group does not exist PostgreSQL log is not ticked under Log exports, or the modification is still being applied.
Card shows Access Error / "no permission" The instance role lacks logs:FilterLogEvents on that group ARN (group and :*). Update the stack parameter or the policy.
Could not list log groups Missing logs:DescribeLogGroups, or a wrong AWS Region in the integration.
Logins missing log_connections is off. Failed logins come from the FATAL: password authentication failed line and are recorded even without log_connections.
A refused statement shows no SQL pgaudit does not log statements that fail before execution; QubeSight records the ERROR line with the error text. Set log_min_error_statement = error to also get the SQL in a STATEMENT: line.
Lines in Queue (unrecognised) Non-default log_line_prefix. Keep the RDS default. Server housekeeping lines (checkpoints, start-up) are counted, not stored.
Events from the activity stream and from CloudWatch both appear Two sources for the same cluster; disable one.
Activity stream does not start Burstable class, Aurora Serverless, or unsupported version; or the KMS key is in another region.