Step 4: Configure the Collector

Configuring the collector on an Amazon EC2 instance

The collector configuration file lives in /etc/pganalyze-collector.conf, and looks like this:

[pganalyze]
api_key = your_pga_organization_api_key

[server1]
db_host = instance-id.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

Fill in the values step-by-step:

  1. The 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, and cluster-ro to the underlying reader instance:

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

For writer instances this is supported for any size of cluster, but for reader instances this is only supported in two-node clusters (i.e. single reader instance).

If you have multiple readers you want to monitor you instead need to specify each instance endpoint separately:

[server_instance1]
db_host = mydbinstance1.123456789012.us-east-1.rds.amazonaws.com
...

[server_instance2]
db_host = mydbinstance2.123456789012.us-east-1.rds.amazonaws.com
...

[server_instance3]
db_host = mydbinstance3.123456789012.us-east-1.rds.amazonaws.com
...

Test snapshot

Now, verify that the configuration is correct, by running the following command:

$ sudo pganalyze-collector --test --reload
1999/01/01 08:04:30 I [pganalyze] Testing statistics collection...
1999/01/01 08:04:32 I [pganalyze] Test submission successful (1010 KB received)

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 →