Step 4: Configure the Collector

Configuring the collector with Docker

Create your configuration file (e.g. named pganalyze_collector.env) with environment variables like this:

PGA_API_KEY=your-organization-api-key
DB_HOST=your_database_host
DB_NAME=your_database_name
DB_USERNAME=your_monitoring_user
DB_PASSWORD=your_monitoring_user_password
DB_SSLROOTCERT=rds-ca-global
DB_SSLMODE=verify-full

Fill in the values step-by-step:

  1. The PGA_API_KEY can be found on the pganalyze Settings page for your organization under the API keys tab
  2. The DB_HOST is the hostname / endpoint of your RDS instance (for Amazon Aurora you can use the cluster endpoint in many cases, see for details below)
  3. The DB_NAME is the database name on the Postgres server you want to monitor
  4. The DB_USERNAME and DB_PASSWORD should be the monitoring user we created in Step 2
  5. The DB_SSLROOTCERT and DB_SSLMODE is the recommended SSL connection configuration that you can usually keep as specified above

Note: The pganalyze collector allows for more optional settings (e.g. AWS access keys, multiple database names)

Handling Amazon Aurora clusters vs instances

In the case of Amazon Aurora, the collector automatically resolves cluster endpoints to the underlying writer instance.

DB_HOST=mydbcluster.cluster-123456789012.us-east-1.rds.amazonaws.com

This will only monitor the writer instance. If you also want to monitor a reader instance, you'll need to use the Multiple Servers method above.

CONFIG_CONTENTS="[pganalyze]
api_key = 'your_pga_organization_api_key'

[server_writer]
db_host = mydbcluster.cluster-123456789012.us-east-1.rds.amazonaws.com
...

[server_reader]
db_host = mydbcluster.cluster-ro-123456789012.us-east-1.rds.amazonaws.com
...
"

Alternatively, you can run a separate Docker container to monitor a reader instance. Create a new configuration file (e.g. named pganalyze_collector.replica.env) and use the cluster-ro endpoint as the DB_HOST:

DB_HOST=mydbcluster.cluster-ro-123456789012.us-east-1.rds.amazonaws.com

If you have multiple readers you want to monitor, you either need to add it to the content of CONFIG_CONTENTS, or run one pganalyze collector Docker container for each instance.

Test snapshot

Then run the following:

docker run --env-file pganalyze_collector.env quay.io/pganalyze/collector:stable test

Once you've confirmed the install is successful and you're receiving query data in pganalyze, we recommend setting up Log Insights as a follow-up step, to automatically track log events in your database.


Couldn't find what you were looking for or want to talk about something specific?
Start a conversation with us →