Skip to content
pgmonitor

pgmonitor

pgmonitor : Collector-friendly metric views and background refresh worker

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
6070
pgmonitor
pgmonitor
2.2.0
STAT
Apache-2.0
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLd--
No
Yes
Yes
Yes
no
no
Relationships
See Also
pgnodemx
system_stats
pg_stat_monitor
pg_profile

Metric objects work without preloading; the optional background worker requires shared_preload_libraries=pgmonitor_bgw.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
2.2.0
18
17
16
15
14
pgmonitor-
RPM
PIGSTY
2.2.0
18
17
16
15
14
pgmonitor_$v-
DEB
PIGSTY
2.2.0
18
17
16
15
14
postgresql-$v-pgmonitor-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
el8.aarch64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
el9.x86_64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
el9.aarch64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
el10.x86_64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
el10.aarch64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
d12.x86_64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
d12.aarch64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
d13.x86_64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
d13.aarch64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
u22.x86_64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
u22.aarch64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
u24.x86_64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
u24.aarch64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
u26.x86_64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
u26.aarch64
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PIGSTY 2.2.0
PackageVersionOSORGSIZEFile URL
pgmonitor_182.2.0el8.x86_64pigsty32.1 KiBpgmonitor_18-2.2.0-1PIGSTY.el8.x86_64.rpm
pgmonitor_182.2.0el8.aarch64pigsty32.3 KiBpgmonitor_18-2.2.0-1PIGSTY.el8.aarch64.rpm
pgmonitor_182.2.0el9.x86_64pigsty31.8 KiBpgmonitor_18-2.2.0-1PIGSTY.el9.x86_64.rpm
pgmonitor_182.2.0el9.aarch64pigsty31.5 KiBpgmonitor_18-2.2.0-1PIGSTY.el9.aarch64.rpm
pgmonitor_182.2.0el10.x86_64pigsty32.0 KiBpgmonitor_18-2.2.0-1PIGSTY.el10.x86_64.rpm
pgmonitor_182.2.0el10.aarch64pigsty31.9 KiBpgmonitor_18-2.2.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-pgmonitor2.2.0d12.x86_64pigsty36.7 KiBpostgresql-18-pgmonitor_2.2.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-pgmonitor2.2.0d12.aarch64pigsty36.5 KiBpostgresql-18-pgmonitor_2.2.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-pgmonitor2.2.0d13.x86_64pigsty36.8 KiBpostgresql-18-pgmonitor_2.2.0-1PIGSTY~trixie_amd64.deb
postgresql-18-pgmonitor2.2.0d13.aarch64pigsty36.6 KiBpostgresql-18-pgmonitor_2.2.0-1PIGSTY~trixie_arm64.deb
postgresql-18-pgmonitor2.2.0u22.x86_64pigsty38.9 KiBpostgresql-18-pgmonitor_2.2.0-1PIGSTY~jammy_amd64.deb
postgresql-18-pgmonitor2.2.0u22.aarch64pigsty38.4 KiBpostgresql-18-pgmonitor_2.2.0-1PIGSTY~jammy_arm64.deb
postgresql-18-pgmonitor2.2.0u24.x86_64pigsty38.0 KiBpostgresql-18-pgmonitor_2.2.0-1PIGSTY~noble_amd64.deb
postgresql-18-pgmonitor2.2.0u24.aarch64pigsty37.8 KiBpostgresql-18-pgmonitor_2.2.0-1PIGSTY~noble_arm64.deb
postgresql-18-pgmonitor2.2.0u26.x86_64pigsty38.2 KiBpostgresql-18-pgmonitor_2.2.0-1PIGSTY~resolute_amd64.deb
postgresql-18-pgmonitor2.2.0u26.aarch64pigsty37.9 KiBpostgresql-18-pgmonitor_2.2.0-1PIGSTY~resolute_arm64.deb

Source

pig build pkg pgmonitor;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pgmonitor;		# install via package name, for the active PG version

pig install pgmonitor -v 18;   # install for PG 18
pig install pgmonitor -v 17;   # install for PG 17
pig install pgmonitor -v 16;   # install for PG 16
pig install pgmonitor -v 15;   # install for PG 15
pig install pgmonitor -v 14;   # install for PG 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pgmonitor_bgw';

Create this extension with:

CREATE EXTENSION pgmonitor;

Usage

Sources:

pgmonitor exposes PostgreSQL monitoring metrics through a curated set of views, materialized views, and tables for external collectors. Its SQL metrics work without a background worker; the optional pgmonitor_bgw worker periodically refreshes materialized data.

Create the Extension

Create a dedicated schema and install pgmonitor there:

CREATE SCHEMA pgmonitor_ext;
CREATE EXTENSION pgmonitor SCHEMA pgmonitor_ext;

Grant collectors only the access they need to the metric objects. Some underlying PostgreSQL statistics remain subject to built-in role and row-visibility rules.

Collect Metrics

External agents can select the active objects described by the extension’s configuration tables:

SELECT *
FROM pgmonitor_ext.metric_views
WHERE active;

SELECT *
FROM pgmonitor_ext.metric_matviews
WHERE active;

SELECT *
FROM pgmonitor_ext.metric_tables
WHERE active;

These tables describe metric name, activation, scope, and refresh interval. Query the installed definitions rather than assuming every metric is enabled on every PostgreSQL version.

The metric surface includes activity, database and table statistics, locks, replication, WAL and archive status, vacuum progress, settings, checkpoints, and extension-specific views when their dependencies are available.

Refresh Materialized Metrics Manually

Without the background worker, invoke the refresh procedure for the configured schema and metric:

CALL pgmonitor_ext.refresh_metrics(
  'pgmonitor_ext',
  'pg_stat_statements'
);

Use names returned by metric_matviews; do not assume the example metric is installed or active. The extension retains a legacy refresh function for compatibility, but new integrations should use the documented procedure.

Optional Background Worker

To schedule refreshes inside PostgreSQL:

shared_preload_libraries = 'pgmonitor_bgw'
pgmonitor_bgw.dbname = 'postgres,app'
pgmonitor_bgw.role = 'postgres'
pgmonitor_bgw.interval = 30

Restart PostgreSQL after changing shared_preload_libraries. pgmonitor_bgw.dbname is required and lists the databases to maintain. Upstream v2.2 currently requires the worker role to be a superuser; use the narrowest controlled role and protect its credentials and settings.

Object Index

  • metric_views: directly queried metric views and their collection metadata.
  • metric_matviews: materialized metrics and refresh intervals.
  • metric_tables: table-backed metrics and maintenance metadata.
  • refresh_metrics(schema, name): refresh procedure for one configured metric.
  • pgmonitor_bgw.dbname: databases processed by the optional worker.
  • pgmonitor_bgw.role: role used for refresh work.
  • pgmonitor_bgw.interval: worker loop interval in seconds.

Version 2.2 and Caveats

Version 2.2 removes the settings-checksum metric, fixes the legacy refresh path on PostgreSQL 13, and reduces routine log noise.

  • Metric queries add load to shared statistics, catalogs, and extension objects. Set collection intervals from measured cost.
  • A healthy collector connection does not prove materialized views are fresh; monitor their timestamps and worker logs.
  • The extension supplies database metrics, not host, filesystem, or process metrics.
  • Installing pgmonitor does not automatically configure Prometheus, exporters, dashboards, or alert rules.
Last updated on