selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

GitHub
PgHero logo

Self-host PgHero

v4.1.0

Postgres performance dashboard with query and space stats

ReleaseOpen SourceMIT
docker run -ti -e DATABASE_URL=postgres://user:password@hostname:5432/dbname -p 8080:8080 ankane/pghero
Updated2 weeks ago
LanguageRuby
Setup difficultyEasy
Stars
8 948
Port
8080 (PgHero web dashboard (container publishes 8080:8080))
Requires
PostgreSQL
Docker
ankane/pghero
PgHero performance dashboard homepage on the demo instance

What is PgHero?

PgHero is a performance dashboard for Postgres, aimed at developers and operators who want database insight without a hosted monitoring product. The web UI reports query statistics, long running and slow queries, connections, table and index space usage, suggested indexes, unused indexes, and lets you inspect plans with EXPLAIN and a visualize page or terminate long running queries and connections. It runs either as the ankane/pghero Docker container pointed at a DATABASE_URL, or as a Rails engine mounted in an existing application. Historical query and space stats are opt-in: you create pghero_* tables and schedule the bundled rake tasks, after which a time range slider appears on the Queries tab. System level metrics such as CPU usage and IOPS come from managed database providers, currently Amazon RDS and Google Cloud SQL. Multiple monitored databases and thresholds are configured through pghero.yml, access is protected with basic auth credentials or left to a reverse proxy, and the container exposes a /health endpoint. Version 4.0 requires Postgres 14 or newer and was released in August 2026.

PgHero alternatives

Should you self-host PgHero?

PgHero scores 67/100 on selfhost.directory (how scoring works) and ranks #1 of 2 in Performance monitoring. It has 8 948 GitHub stars, +16 in the last 30 days.

There was no stable release in the past 12 months, so check the repository's recent activity before you rely on it.

Setup is easy: most people get it running in one sitting. An official Docker image is available. It is MIT-licensed and written mostly in Ruby.

Its closest alternative on selfhost.directory is Bencher (54/100, 928 stars). PgHero scores higher overall. See PgHero vs Bencher side by side.

Features

  • Basic Authentication
  • Configurable alert thresholds
  • EXPLAIN and plan visualization
  • Health check endpoint
  • Historical query statsOpt-in: requires creating the stats tables and scheduling rake tasks.
  • Historical space stats
  • Index suggestions
  • Kill long running queries and connections
  • Multiple database monitoring
  • Query performance stats
  • System stats for managed databasesRDS requires the aws-sdk-cloudwatch gem / CloudWatch IAM permission; Cloud SQL requires the Monitoring API.
  • Unused index detection

PgHero README

How to install PgHero

Install PgHero with Docker

Environment variables
DATABASE_URL, PGHERO_USERNAME, PGHERO_PASSWORD

PgHero is available on Docker Hub.

docker pull ankane/pghero

Start the dashboard:

docker run -ti -e DATABASE_URL=postgres://user:password@hostname:5432/dbname -p 8080:8080 ankane/pghero

How to configure PgHero

  • DATABASE_URLConnection string of the Postgres database to monitor (Docker)
  • PGHERO_USERNAMEUsername for basic authentication to the dashboard
  • PGHERO_PASSWORDPassword for basic authentication to the dashboard
  • PGHERO_STATS_DATABASE_URLDatabase used to store historical query/space stats when it is not the monitored one
  • AWS_ACCESS_KEY_IDAWS credentials for RDS system stats (Docker)

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…