DEV.co
Open-Source Databases · dalibo

pg_activity

pg_activity is a terminal-based monitoring tool for PostgreSQL that displays real-time server activity similar to the Unix 'top' command. It provides visibility into running queries, resource consumption, and system metrics with an interactive CLI interface.

Source: GitHub — github.com/dalibo/pg_activity
3k
GitHub stars
191
Forks
Python
Primary language
PostgreSQL
License (Requires review (not clearly OSI))

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorydalibo/pg_activity
Ownerdalibo
Primary languagePython
LicensePostgreSQL — Requires review (not clearly OSI)
Stars3k
Forks191
Open issues15
Latest releasev3.6.2 (2026-06-05)
Last updated2026-07-02
Sourcehttps://github.com/dalibo/pg_activity

What pg_activity is

Python-based CLI tool that connects to PostgreSQL via psycopg driver, queries pg_stat_statements and system catalogs, and renders live activity data in a sortable, filterable terminal UI. Requires superuser or elevated OS permissions for full visibility into system resources and temporary files.

Quickstart

Get the pg_activity source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/dalibo/pg_activity.gitcd pg_activity# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Real-time Query Monitoring

Monitor active queries, connection counts, and query durations across databases without external monitoring infrastructure.

Performance Troubleshooting

Quickly identify slow queries, blocking sessions, and resource-intensive operations during performance investigations.

Development and Testing

Developers can inspect database activity on local PostgreSQL instances during application development and testing cycles.

Implementation considerations

  • Requires Python 3.x runtime; install via pip, package managers (apt, yum), or pipx for isolated environments.
  • Connect with superuser PostgreSQL account to access system information and tempfile data; fallback to degraded mode with standard user.
  • Run with OS-level superuser (sudo) or as postgres system user for local execution to read system metrics accurately.
  • Configure track_activity_query_size parameter if query text appears truncated; default 1024 bytes may be insufficient.
  • Supports AWS RDS with --rds flag; filters rdsadmin database and disables tempfile monitoring for RDS limitations.

When to avoid it — and what to weigh

  • Large-scale Multi-instance Monitoring — Not designed for centralized monitoring of hundreds of database instances; better served by dedicated monitoring platforms.
  • Persistent Historical Analysis — Tool is real-time only with no built-in time-series storage; use Prometheus/Grafana for historical trending and alerting.
  • Highly Restrictive Database Access — Requires superuser or equivalent privileges for full functionality; degraded mode with reduced visibility if permissions are limited.
  • Automated Alert and Escalation — No native alerting; requires manual observation or external scripting to trigger automated responses.

License & commercial use

Licensed under PostgreSQL License (also known as the Postgres License). This is a permissive open-source license allowing modification, distribution, and private use with minimal restrictions.

PostgreSQL License permits commercial use. However, verify compatibility with your specific commercial deployment terms and consult legal review if required by your organization's policy.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceHigh
Security considerations

Tool queries live database activity; requires secure credential handling (connection strings, environment variables). Superuser access needed for full visibility—consider using dedicated read-only monitoring role if feasible. No explicit security audit or CVE history provided in data; review project security advisories before production use.

Alternatives to consider

pgAdmin

Web-based PostgreSQL management; broader feature set but heavier deployment and network overhead.

DBeaver

Desktop IDE with activity monitoring; more feature-rich but requires GUI and local installation.

Prometheus + pg_exporter

Centralized monitoring with time-series storage and alerting; better for multi-instance and historical analysis.

Software development agency

Build on pg_activity with DEV.co software developers

Integrate pg_activity into your development and operations workflow. Contact our team for guidance on deployment in your environment.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

pg_activity FAQ

Can pg_activity monitor remote PostgreSQL instances?
Yes. Provide a connection string with host/port/user/dbname. Local execution (same machine as postgres) provides additional system metrics; remote execution works but without OS-level system information.
What permissions does the PostgreSQL user need?
Superuser role is recommended for full visibility into all queries and metadata. Non-superuser roles work in degraded mode with limited system info and tempfile visibility.
Does pg_activity store historical data?
No. It displays real-time activity only. Use the --output flag to export current queries to CSV, or integrate with external time-series systems like Prometheus for historical analysis.
Is pg_activity suitable for production monitoring?
Yes, as a real-time operational tool for manual inspection. For automated alerting, escalation, and dashboarding in production, combine with Prometheus/Grafana or a dedicated monitoring platform.

Software developers & web developers for hire

DEV.co helps companies turn open-source tools like pg_activity into production software. Our software development services cover the full lifecycle — architecture, web development, integration, and maintenance — delivered by software developers and web developers who ship. Engage our software development agency to implement or customize it for your open-source databases stack.

Ready to Monitor PostgreSQL Activity?

Integrate pg_activity into your development and operations workflow. Contact our team for guidance on deployment in your environment.