pg_eyes
pg_eyes · SQL monitoring functions and views for PostgreSQL database activity
Overview
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
| Relationships | |
|---|---|
| Requires | pg_stat_statements plpgsql |
Usage
Sources:
pg_eyes 1.4 is a pure-SQL monitoring toolkit in the fixed eyes schema. It exposes activity, lock, size, catalog, settings, replication, and pg_stat_statements data as ready-to-scrape metrics and views. Upstream’s 1.x branch targets PostgreSQL 9.6, so verify every object on newer catalogs before use.
Setup and Basic Queries
pg_stat_statements must be installed and loaded correctly, normally through shared_preload_libraries, before its statistics are useful. The extension itself requires superuser installation and is not relocatable.
The spelling active_queryes, blocked_queryes, and top_queryes is part of the upstream SQL API.
Important Objects
eyes.get_activity()returns metric-name/value rows for sessions, transactions, database and background-writer counters, WAL, replication, and response time.eyes.get_activity(text)runs custom scalar metric SQL stored in the tableeyes.get_activityfor the selected group.eyes.get_pg_stat_activity()andeyes.get_pg_stat_statements()areSECURITY DEFINERwrappers owned bypostgres.eyes.db_objects,eyes.db_tables,eyes.db_tables_size,eyes.db_indexes,eyes.db_indexes_size,eyes.db_attributes,eyes.db_functions, andeyes.db_settingsexpose inventory and configuration details.
Many counters are cumulative and must be converted to rates by the monitoring system. Metrics ending in _time use milliseconds according to the upstream README.
Security and Compatibility
The definer-rights wrappers intentionally expose complete activity and statement text to non-superusers who can execute them. Query text, client addresses, settings paths, and function definitions can be sensitive; explicitly audit and narrow EXECUTE and schema privileges after installation.
eyes.get_activity(text) executes the stat_query column as the function owner. Never grant untrusted roles write access to the eyes.get_activity table, and review every custom metric before insertion. Older upgrade paths may also retain definer-rights administrative functions; inspect effective grants with \df+ eyes.*.
Version 1.4 SQL refers to PostgreSQL 9.6-era catalog columns such as the historical pg_stat_statements.total_time. It is not evidence of compatibility with all later majors. Test installation and every selected view against the exact PostgreSQL and pg_stat_statements versions, or port the SQL before production deployment.