This is a fork of pgweasel as rewrite in RUST.
A simple CLI usage oriented PostgreSQL log parser, to complement pgBadger.
pgweasel tries to:
- be an order of magnitude faster than pgBadger
- way simpler, with less flags, operating rather via commands and sub-commands
- focus on CLI interactions only - no html / json
- more cloud-friendly - no deps, a single binary
- zero config - not dependent on Postgres log_line_prefix
- be more user-friendly - handle relative time inputs, auto-detect log files, subcommand aliases
This project is in BETA. Command / subcommands "API" might change.
MAC & Linux targts passes tests. Windows - needs testers.
You can download binaries from GitHub Releases.
Make sure, you have RUST compiler installed. Then:
git clone https://github.com/gintsgints/pgweasel.git
cd pgweasel
cargo build --release
The built binary will be in target/release/pgweasel.Here is a list of currently implemented commands
-
pgweasel errors $LOG(s)- Show WARN+ (by default) log entries "as is" -
pgweasel errors --begin 10m $LOG(s)- Show entries from last 10min -
pgweasel errors -l error $LOG(s)- Show ERROR+ entries -
pgweasel error top ./tests/files/debian_default2.log- Show top LOG message count -
pgweasel -t "2025-05-21 13:00:00" errors -l LOG testdata/csvlog_pg14.csv- Show LOG entries with timestamp begining with '2025-05-21 13:00:00' -
pgweasel -t "2025-05-21 13:00:00" errors -l LOG testdata/csvlog1.csv.gz- Show LOG entries with timestamp begining with '2025-05-21 13:00:00' -
pgweasel errors --debug $LOG(s)- Show LOG entries with debug info including execution time. -
pgweasel errors hist $LOG- Show a basic vertical histogram of error counts. Default --bucket=1h -
pgweasel errors hist -b 3m -l debug5 $LOG- Show a histogram for all events, not only errors, using --bucket=3m
-
pgweasel locks ./tests/files/locking.logOnly show locking entries (incl. deadlocks, recovery conflicts)
-
pgweasel peaks $LOGShow the "busiest" time periods with most log events, using a 10min bucket by default
-
pgweasel slow 1s ./testdata/csvlog_pg14.csv- Show LOG entries that took longer than 1second. -
pgweasel slow top ./testdata/cloudsql.log- Show top 10 slowest queries. -
pgweasel slow stat $LOGShow avg slow log exec times per query type
-
pgweasel stats $LOGSummary of log events - counts / frequency of errors, connections, checkpoints, autovacuums
-
pgweasel system testdata/debian_default.logShow lifecycle / Postgres internal events, i.e. autovacuum, replication, extensions, config changes etc
-
pgweasel connections ./tests/files/azure_connections.logShow connections counts by total, db, user, application name. Assumes log_connections enabled
For grep I would recommend using grep cli - ripgrep
All kinds of feedback and help (PR-s, co-maintainer) would be much appreciated. Hopefully pgweasel will grow into a community project with rock solid quality.
When creating MR, make sure cargo test and cargo fmt --all -- --check pass.
Have sample log files ? I've scraped the Postgres mailing archives for *.log attachements (in testdata folder), but they are not much sadly...so if you have some real-life logs from busy or somehow "troublesome" instances, not containing secrets - please add one one via PR or proide some S3 etc link under issues. Thank you!
pgweasel is free software distributed under the Apache Licence.