2 query: "SELECT CASE WHEN NOT pg_is_in_recovery() THEN 0 ELSE GREATEST (0, EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))) END AS lag_seconds"
7 description: "Replication lag behind master in seconds"
10 query: "SELECT pg_postmaster_start_time as start_time_seconds from pg_postmaster_start_time()"
15 description: "Time at which postmaster started"
16 <% if node[:postgresql][:monitor_tables] -%>
19 query: "SELECT current_database() datname, schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze, COALESCE(last_vacuum, '1970-01-01Z') as last_vacuum, COALESCE(last_autovacuum, '1970-01-01Z') as last_autovacuum, COALESCE(last_analyze, '1970-01-01Z') as last_analyze, COALESCE(last_autoanalyze, '1970-01-01Z') as last_autoanalyze, vacuum_count, autovacuum_count, analyze_count, autoanalyze_count FROM pg_stat_user_tables"
23 description: "Name of current database"
26 description: "Name of the schema that this table is in"
29 description: "Name of this table"
32 description: "Number of sequential scans initiated on this table"
35 description: "Number of live rows fetched by sequential scans"
38 description: "Number of index scans initiated on this table"
41 description: "Number of live rows fetched by index scans"
44 description: "Number of rows inserted"
47 description: "Number of rows updated"
50 description: "Number of rows deleted"
53 description: "Number of rows HOT updated (i.e., with no separate index update required)"
56 description: "Estimated number of live rows"
59 description: "Estimated number of dead rows"
60 - n_mod_since_analyze:
62 description: "Estimated number of rows changed since last analyze"
65 description: "Last time at which this table was manually vacuumed (not counting VACUUM FULL)"
68 description: "Last time at which this table was vacuumed by the autovacuum daemon"
71 description: "Last time at which this table was manually analyzed"
74 description: "Last time at which this table was analyzed by the autovacuum daemon"
77 description: "Number of times this table has been manually vacuumed (not counting VACUUM FULL)"
80 description: "Number of times this table has been vacuumed by the autovacuum daemon"
83 description: "Number of times this table has been manually analyzed"
86 description: "Number of times this table has been analyzed by the autovacuum daemon"
88 pg_statio_user_tables:
89 query: "SELECT current_database() datname, schemaname, relname, heap_blks_read, heap_blks_hit, idx_blks_read, idx_blks_hit, toast_blks_read, toast_blks_hit, tidx_blks_read, tidx_blks_hit FROM pg_statio_user_tables"
93 description: "Name of current database"
96 description: "Name of the schema that this table is in"
99 description: "Name of this table"
102 description: "Number of disk blocks read from this table"
105 description: "Number of buffer hits in this table"
108 description: "Number of disk blocks read from all indexes on this table"
111 description: "Number of buffer hits in all indexes on this table"
114 description: "Number of disk blocks read from this table's TOAST table (if any)"
117 description: "Number of buffer hits in this table's TOAST table (if any)"
120 description: "Number of disk blocks read from this table's TOAST table indexes (if any)"
123 description: "Number of buffer hits in this table's TOAST table indexes (if any)"
133 SUM(EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - state_change))::bigint)::float AS process_idle_seconds_sum,
134 COUNT(*) AS process_idle_seconds_count
135 FROM pg_stat_activity
136 WHERE state ~ '^idle'
137 GROUP BY state, application_name
145 CASE WHEN EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - state_change)) <= le
152 UNNEST(ARRAY[1, 2, 5, 15, 30, 60, 90, 120, 300]) AS le
153 GROUP BY state, application_name, le
154 ORDER BY state, application_name, le
159 process_idle_seconds_sum as seconds_sum,
160 process_idle_seconds_count as seconds_count,
161 ARRAY_AGG(le) AS seconds,
162 ARRAY_AGG(bucket) AS seconds_bucket
163 FROM metrics JOIN buckets USING (state, application_name)
172 description: "Application Name"
175 description: "Idle time of server processes"
178 query: "SELECT current_database() AS datname, max(age(relfrozenxid)) AS xid_age, max(mxid_age(relminmxid)) AS mxid_age FROM pg_class WHERE relkind IN ('r', 'm')"
182 description: "Name of the database"
185 description: "Age of the oldest unfrozen transaction ID in this database"
188 description: "Age of the oldest unfrozen multixact ID in this database"
191 query: "SELECT count(*) AS segment_count FROM pg_ls_waldir() WHERE name ~ '^[0-9A-Z]{24}$'"
196 description: "Number of WAL segments"