Skip to content

Latest commit

 

History

History
87 lines (56 loc) · 2.01 KB

Heroku.md

File metadata and controls

87 lines (56 loc) · 2.01 KB

PgHero for Heroku

One click deployment

Deploy

Authentication

Set the following variables in your environment.

heroku config:set PGHERO_USERNAME=link
heroku config:set PGHERO_PASSWORD=hyrule

Query Stats

Query stats are enabled by default for Heroku databases - there’s nothing to do 🎉

For databases outside of Heroku, query stats can be enabled from the dashboard.

If you run into issues, view the guide.

Historical Query Stats

To track query stats over time, create a table to store them.

CREATE TABLE "pghero_query_stats" ("id" serial primary key, "database" text, "query" text, "total_time" float, "calls" bigint, "captured_at" timestamp)
CREATE INDEX "index_pghero_query_stats_on_database_and_captured_at" ON "pghero_query_stats" ("database", "captured_at")

This table can be in the current database or another database. If another database, run:

heroku config:set PGHERO_STATS_DATABASE_URL=...

Schedule the task below to run every 5 minutes.

rake pghero:capture_query_stats

Or with a scheduler like Clockwork, use:

PgHero.capture_query_stats

After this, a time range slider will appear on the Queries tab.

System Stats

CPU usage is available for Amazon RDS. Add these variables to your environment:

heroku config:set PGHERO_ACCESS_KEY_ID=accesskey123
heroku config:set PGHERO_SECRET_ACCESS_KEY=secret123
heroku config:set PGHERO_DB_INSTANCE_IDENTIFIER=epona

Customize

Minimum time for long running queries

heroku config:set PGHERO_LONG_RUNNING_QUERY_SEC=60 # default

Minimum average time for slow queries

heroku config:set PGHERO_SLOW_QUERY_MS=20 # default

Minimum calls for slow queries

heroku config:set PGHERO_SLOW_QUERY_CALLS=100 # default

Minimum connections for high connections warning

heroku config:set PGHERO_TOTAL_CONNECTIONS_THRESHOLD=100 # default