Skip to content

pg_argus

Schedule read-only SQL metric collection and OTLP export

pg_argus · Schedule read-only SQL metric collection and OTLP export

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102464pg_arguspg_argus0.3.0STATApache-2.0Rust

PostgreSQL · 18, 19

Usage

Sources:

pg_argus runs scheduled SQL queries inside PostgreSQL and exports their results as OpenTelemetry metrics over OTLP/HTTP. Release 0.3.0 unifies the repository crates and packages under one release version. Its independent SQL/control version is 1.0. Supported platforms are Linux amd64 and arm64 with PostgreSQL 18 or 19; this remains an early preview.

Enable Collection

After installing the matching library, create a monitoring role as an administrator. The collector uses the configured role’s database privileges; it does not use a client password or consume a normal client connection slot.

CREATE ROLE argus_monitor NOLOGIN IN ROLE pg_monitor;

Add the library to the existing preload list and configure the endpoint and query files:

shared_preload_libraries = 'pg_argus'
pg_argus.role = 'argus_monitor'
pg_argus.otlp_endpoint = 'https://collector.example.internal:4318'
pg_argus.metrics_files = '/etc/pg_argus/queries.yaml'

Increase max_worker_processes by 2 plus pg_argus.max_collectors (default 2), then restart PostgreSQL. Preserve other entries already in shared_preload_libraries. Query files use the CloudNativePG Monitoring custom-query format. Grant the monitoring role access to each monitored database and the objects its queries need; CloudNativePG may require explicit database CONNECT grants.

Observe Workers

Preloading starts collection. Creating the extension is optional and supplies the status function in the fixed argus schema; it requires a superuser and an already preloaded library.

CREATE EXTENSION pg_argus;
SELECT * FROM argus.status();

The launcher schedules per-database collectors and maintains the current shared-memory samples. A separate exporter performs network I/O. Collectors use read-only transactions with statement and lock limits. A superuser monitoring role is rejected. Set pg_argus.metric_prefix to cnpg when using dashboards expecting CloudNativePG metric names.

Operational Limits

This source is a preview whose production readiness remains under review. Only metrics are implemented in the reviewed revision: query events and server-log export are design work, even though status columns reserve space for them. Export failures do not block SQL collection, but samples are not a durable delivery queue. Protect query files, TLS material and endpoint configuration as server configuration, and avoid sensitive query results or unbounded label cardinality.

Table reader