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-fullFill in the values step-by-step:
-
The
PGA_API_KEYcan be found on the pganalyze Settings page for your organization under the API Access tab - The
DB_HOSTis the hostname / endpoint of your RDS instance (for Amazon Aurora you can use the cluster endpoint in many cases, see for details below) - The
DB_NAMEis the database name on the Postgres instance you want to monitor - The
DB_USERNAMEandDB_PASSWORDshould be the monitoring user we created in Step 2 - The
DB_SSLROOTCERTandDB_SSLMODEis the recommended SSL connection configuration that you can usually keep as specified above
CONFIG_CONTENTS="[pganalyze]
api_key = your_pga_organization_api_key
[instance1]
db_host = instance-id1.account-id.us-east-1.rds.amazonaws.com
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
[instance2]
db_host = instance-id2.account-id.us-east-1.rds.amazonaws.com
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"This multiline variable definition with the .env file is only supported by
Docker Compose and not by the Docker CLI (docker run).
If you want to use the Docker CLI with CONFIG_CONTENTS, you can pass this
directly as an environment variable, like the following:
docker run -e CONFIG_CONTENTS="
[pganalyze]
api_key = ..." quay.io/pganalyze/collector:stable testAlternatively, run one pganalyze collector Docker container for each instance using the Single Instance method.
Fill in the values step-by-step:
-
The
api_keycan be found on the pganalyze Settings page for your organization under the API Access tab - The
db_hostis the hostname / endpoint of your RDS instance (for Amazon Aurora you can use the cluster endpoint in many cases, see for details below) - The
db_nameis the database name on the Postgres instance you want to monitor - The
db_usernameanddb_passwordshould be the monitoring user we created in Step 2 - The
db_sslrootcertanddb_sslmodeis 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.comThis will only monitor the writer instance. If you also want to monitor a reader instance, you’ll need to use the Multiple Instances method above.
CONFIG_CONTENTS="[pganalyze]
api_key = 'your_pga_organization_api_key'
[writer_instance]
db_host = mydbcluster.cluster-123456789012.us-east-1.rds.amazonaws.com
...
[reader_instance]
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.comIf you have a cluster with multiple readers, you either need to add each instance
endpoint to the content of CONFIG_CONTENTS (e.g. add each sections like [reader_instance1], [reader_instance2]),
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 testOnce 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 →