Postgres Café: Expand monitoring capabilities with StatsMgr
2025 has begun, and with it we’re excited to release the second episode of Postgres Café, a blog and video series from our teams over at Data Bene and Xata made with the intention of exploring the world of open source and where it meets PostgreSQL’s extensibility. Throughout this series, we discuss different extensions and tools that enhance the developer experience when working with PostgreSQL. In our second episode, we explore a brand new PostgreSQL extension called StatsMgr that leverages background workers and shared memory to snapshot, manage, and query various statistics for WAL, SLRU, IO, checkpointing, and more.
Episode 2: StatsMgr
In this episode, we introduce the just-released open source extension StatsMgr, created to continuously monitor and track events across PostgreSQL and the underlying system. Here’s a look at what this episode covered:
Customized metrics processing
Originally the idea was to provide a simplified interface for metrics, while enhancing them with a wide variety of available types. This functionality was then expanded to address problems like:
- Making statistics available for collection from external systems, without interruption even when those external systems are down.
- Providing an immediate view of PostgreSQL statistics with historical tracking, including pg_stat views & functions.
- Increasing & reducing the amount of historical records when needed with dynamic buffer allocation.
- Debugging PostgreSQL instances with historical analysis and without required restarts.
This extension, in turn, is great at handling situations like when…
- …your monitoring agent is down; using StatsMgr as a backup allows you to ensure you won’t lose statistics in this event, as events are captured regardless and stored for collection later on by your monitoring agent.
- …you have spikes or otherwise unusual behavior on your production system. This extension allows you to get an overview of activity for useful debugging insights.
Expansive & historical metrics collection
Currently, supported statistics include:
- WAL
- SLRU
- BGWriter
- Checkpointer
- Archiver
- IO
Each of these is registered with a handler that lets you fetch and manage these statistics, and also is accompanied by shared memory structures for storing historical snapshots.
Some of the next steps for the project will include adding in dynamic statistics such as pg_stat_user_tables, amongst others.
There are still many things to do, from subtle improvements to major new features. So of course there’s many opportunities to contribute to the project, no matter if you’re a new-comer or an advanced PostgreSQL developer. Interested in being a part of the effort? Check out CONTRIBUTING.md within the project.
Watch the full episode
For an in-depth exploration of StatsMgr and its capabilities, watch the full episode here:
Stay tuned for more Postgres tools
We still have much more to come for Postgres Café. Subscribe to the playlist for episodes that feature more open-source tools like pgroll for zero-downtime schema migrations, Citus Data for distributed and scalable PostgreSQL as an extension, and more. Watch this space to learn how each tool can make working with Postgres smoother and more efficient.