DEV.co
Open-Source Databases · darold

pgbadger

pgBadger is a fast PostgreSQL log analyzer that parses server logs and generates detailed HTML, text, JSON, or binary reports with performance metrics, query statistics, and graphical visualizations. It supports multiple log formats (syslog, stderr, CSV, JSON, RDS, Redshift) and offers parallel processing for large log volumes.

Source: GitHub — github.com/darold/pgbadger
4k
GitHub stars
376
Forks
Perl
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
Repositorydarold/pgbadger
Ownerdarold
Primary languagePerl
LicensePostgreSQL — Requires review (not clearly OSI)
Stars4k
Forks376
Open issues19
Latest releasev13.2 (2025-12-29)
Last updated2026-06-01
Sourcehttps://github.com/darold/pgbadger

What pgbadger is

Written in Perl, pgBadger processes PostgreSQL logs to extract query performance data, connection patterns, errors, and lock contention, then renders interactive HTML dashboards with configurable aggregation windows (5-minute averages, hourly histograms). It supports incremental parsing for ongoing monitoring and can operate on stdin or remote files via SSH.

Quickstart

Get the pgbadger source

Clone the repository and explore it locally.

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

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

Best use cases

PostgreSQL Performance Tuning & Baseline Analysis

Extract slow query patterns, identify expensive operations, and track query frequency over time to guide index creation, query optimization, and configuration changes.

Production Incident Root-Cause Analysis

Quickly correlate error messages, lock events, checkpoint times, and autovacuum activity within a specific timeframe to diagnose performance degradation or application failures.

Continuous Database Health Monitoring

Deploy in incremental mode with log rotation to generate daily or weekly reports, auto-purge old data after N weeks, and track trends in connection counts, query latency, and database errors.

Implementation considerations

  • Ensure PostgreSQL log_min_duration_ms, log_statement, and log_line_prefix are correctly configured before running pgBadger; unset or non-standard prefixes require manual -p flag tuning.
  • Plan log rotation strategy: pgBadger can read compressed logs (.gz, .bz2) and pipe from commands, but incremental mode with --last-parsed requires careful timestamp tracking.
  • Allocate sufficient disk for HTML output and binary cache files, especially in incremental mode. Retention policy (-R flag) helps auto-cleanup older reports.
  • Test query anonymization (--anonymize) if sensitive data must be hidden in shared reports.
  • For very large log files, use -j (parallel jobs within file) and -J (parallel files) to reduce wall-clock time; monitor CPU and memory usage.

When to avoid it — and what to weigh

  • Real-time Alerting Required — pgBadger generates post-hoc reports; it does not emit alerts on thresholds. Use it for analysis, not live monitoring.
  • No PostgreSQL Log Access — The tool requires postgres logs already enabled and accessible. If logging is disabled or inaccessible, pgBadger cannot operate.
  • Minimal Perl Ecosystem in Environment — pgBadger depends on Perl and modules like JSON::XS. Environments without Perl or restrictive package management may face friction.
  • Extremely Large Log Volumes (TB+) — While parallel processing helps, parsing terabyte-scale logs may exhaust memory or disk I/O. Unknown performance envelope at extreme scale.

License & commercial use

pgBadger is released under the PostgreSQL License (also known as the PostgreSQL License or Postgres License), which is a permissive OSI-approved license similar in spirit to BSD. It allows commercial and proprietary use with minimal restrictions (retain copyright notice).

The PostgreSQL License explicitly permits commercial use, modification, and redistribution with attribution. No GPL-style copyleft obligations. Safe for commercial deployment and resale, but confirm specific license terms for your jurisdiction and use case.

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

pgBadger parses logs that may contain sensitive queries, literals, or PII. The --anonymize flag helps mask literals, but review log_line_prefix to avoid logging passwords or tokens. No built-in encryption for output files; protect HTML reports as confidential. Use -c, -d, -u filters to reduce scope and surface area. No official security audit or vulnerability disclosure policy documented.

Alternatives to consider

pgAdmin / pgAdmin 4

Offers GUI dashboard and basic log viewing, but less detailed query analysis and report generation. Better for interactive admin tasks, weaker for batch reporting.

Percona Monitoring and Management (PMM)

Enterprise-grade monitoring with real-time alerting, distributed storage, and Grafana dashboards. Higher overhead, requires agent deployment, but supports multiple databases and continuous monitoring.

Datadog / New Relic PostgreSQL APM

Cloud-native observability with live alerting and detailed performance traces. Proprietary, requires agent, higher cost. Best for SaaS environments; less suitable for on-premises air-gapped deployments.

Software development agency

Build on pgbadger with DEV.co software developers

pgBadger helps teams identify performance bottlenecks and optimize queries. Download the tool, configure your PostgreSQL logs, and generate your first performance report today.

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.

pgbadger FAQ

Does pgBadger require changes to my PostgreSQL server?
pgBadger only reads existing logs; it does not modify the server. However, you must enable PostgreSQL logging (log_statement, log_min_duration_ms, log_connections, etc.) in postgresql.conf to capture data. No server restart side effects.
Can I use pgBadger for real-time monitoring?
No. pgBadger is a batch log analyzer that generates reports after logs are written. For real-time alerting, integrate with log streaming (e.g., syslog → alerting system) or use continuous monitoring tools like Prometheus + postgres_exporter.
What Perl modules are required?
Core modules are usually included. JSON::XS is required only for --extension json output. Other optional modules may be needed for advanced features; check documentation or run pgbadger --help for hints.
How does incremental mode work and when should I use it?
Incremental mode (--incremental) processes new logs since the last run (tracked via --last-parsed), generating one report per day. Use it for continuous monitoring with daily/weekly cleanup (--retention). Avoids re-parsing entire log history.

Work with a software development agency

From first prototype to production, DEV.co delivers software development services around tools like pgbadger. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across open-source databases and beyond.

Ready to Analyze Your PostgreSQL Logs?

pgBadger helps teams identify performance bottlenecks and optimize queries. Download the tool, configure your PostgreSQL logs, and generate your first performance report today.