Check out our Resources section: Read through our eBooks, compare us to other solutions, and learn how customers are using pganalyze. See all resources.

Step 1: Determine Log Location

Log Insights works by continuously tailing your local Postgres log files, classifying log lines, and submitting log data and statistics to pganalyze. The self-managed configuration requires your collector to run on the same instance as your Postgres server.

You will need to configure the db_log_location in the pganalyze-collector.conf file, and set it to either the filename of the Postgres log file, or the directory in which log files are located.

We provide a helper for discovering the log directory, which you must run as root or using sudo. Run the command like this:

sudo pganalyze-collector --discover-log-location

This will then produce output like this:

2018/05/20 19:51:30 I [server1] Found log location, add this to your pganalyze-collector.conf in the [server1] section:
db_log_location = /var/log/postgresql/postgresql-9.3-main.log

Or alternately, you may get a warning, in which case some extra configuration is necessary. In some cases where discovery doesn't work you might have to review in more detail how your system is set up. Please reach out to pganalyze support for help if needed.

Otherwise, continue below according to the output:

Note that both individual files and directories are supported for db_log_location.

If the db_log_location was discovered by the collector, you only need to confirm that the pganalyze user has access to the log files. Check this with ls:

ls -l [discovered_log_location]

This will show output like

-rw-r----- 1 postgres adm 0 Feb 17 00:00 /var/log/postgresql/postgresql-13-main.log

The fourth field here (adm in this case) is the group that owns the log files. If this is not adm on your system, you should add the pganalyze user to this group. E.g., if the owning group is postgres, run the following:

sudo usermod -a -G postgres pganalyze

Then, update the file permissions of newly created log files to ensure group read permissions:

ALTER SYSTEM SET log_file_mode = '0640';
SELECT pg_reload_conf();
Continue to Step 2: Configure collector

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