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:
-
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.

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

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

-
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.

-
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 initialadminpassword.
-
Open the web address, sign in as
adminwith the password from the secret and set a new password when asked.

-
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.

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¶
-
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.
-
Open the group, choose Edit and set:
Parameter Value Why shared_preload_librariesadd pgauditto the existing list, for examplepg_stat_statements,pg_tle,pgauditLoads pgaudit. Static: needs a reboot of instances that already use the group. pgaudit.logddl,role,write,readStatement classes to audit (see the table below). pgaudit.rolerds_pgauditOptional; needed only for object-level auditing (see below). log_connections1Successful logins (and the client address). log_disconnections1Logouts with the session duration. Leave
log_line_prefixat the RDS default%t:%r:%u@%d:[%p]:; QubeSight relies on it to read the user, database and client.


-
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.

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

-
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_librariesis 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:
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¶
- Select the database and choose Modify.
-
Under Additional monitoring settings → Log exports tick PostgreSQL log.

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

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:

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.


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:
- 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.
-
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/postgresqlA trailing
*covers several groups, for examplearn:aws:logs:us-east-1:111122223333:log-group:/aws/rds/instance/*. -
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.

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

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¶
- Open Data Sources → Stream Sources → AWS CloudWatch Logs and choose New integration.
- Enter an Integration Name (events are tagged
cloudwatch:<name>) and the AWS Region of the databases. The form starts witheu-central-1; change it. - 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). - First read goes back (min): how much history to read at the start, for example
60.0starts from the moment you save. -
Leave Role ARN, External ID and the access keys empty: the instance role is used. Choose Save, then Test.

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:

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 |







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.
- 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. -
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.

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. -
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:Decryptrestricted to RDS activity-stream data keys.
-
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 provekms:Decrypt.
-
Verify with the same workload as in step 6. Events from the activity stream are tagged
kinesis:<name>; heartbeat records are counted, not stored.
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_destinationonly offersstderr,csvlogandjsonloginto 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 forrds.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. |