Log Insights: Install on Heroku Postgres
Assuming you have already followed the installation guide for Heroku Postgres this describes how you can get Log Insights data into pganalyze for your Heroku Postgres database.
Note that this also assumes you are on the pganalyze Scale plan, or are in your initial 14-day trial period.
Log output support is only available on Heroku Postgres Standard, Premium and higher plans.
Log output for Heroku Postgres databases is sent to the application that the database is attached to, so we need to add a log drain to that application that forwards log lines to the pganalyze collector app running in your account.
The collector receives log drains at the following URL:
For the [ALIAS] value we recommend you use the add-on attachment name you've chosen
in the initial setup, which you can determine by viewing the current Heroku
configuration of your collector app (e.g.
heroku config -a testapp-pganalyze-collector
=== testapp-pganalyze-collector Config Vars TESTAPP_URL: postgres://...:...@...:.../... PGA_API_KEY: ...
So in this case we would use
TESTAPP_URL as our alias, and then we would add the log drain
heroku drains:add https://testapp-pganalyze-collector.herokuapp.com/logs/TESTAPP_URL -a testapp
Make sure to replace
testapp-pganalyze-collector with the name of your own collector application that you've deployed in your Heroku account.
First you can verify whether the log drain data is coming by looking at the router logs of the collector app:
heroku logs -a testapp-pganalyze-collector
2018-05-20T21:20:40.993026+00:00 heroku[router]: at=info method=POST path="/logs/TESTAPP_URL" host=testapp-pganalyze-collector.herokuapp.com request_id=564088b7-05a9-4def-8aa0-3861b25f9334 fwd="126.96.36.199" dyno=web.1 connect=0ms service=0ms status=200 bytes=135 protocol=https
To finish, restart the collector app:
heroku restart -a testapp-pganalyze-collector
Afterwards, check the app logs again.
heroku logs -a testapp-pganalyze-collector -t
If the collector was able to match the log data to the correct database, you will see a log line like this after about a minute:
2018-05-20T21:22:19.854980+00:00 app[web.1]: I [TESTAPP_URL] Submitted compact logs snapshot successfully
And then when you check the pganalyze interface, you will see Log Insights data:
Note that on Heroku Postgres you have limited configuration options, but you may want to review the defaults of:
log_min_duration_statement = 2000 log_lock_waits = on log_statement = ddl
You can see details on what these settings do in our tuning guide.
Couldn't find what you were looking for or want to talk about something specific?
Start a conversation with us →