Skip to content

Commit 4318b76

Browse files
authored
PMM-8618 Extend PostgreSQL monitoring (percona#54)
1 parent a39ecde commit 4318b76

File tree

1 file changed

+159
-158
lines changed

1 file changed

+159
-158
lines changed

queries.yaml

Lines changed: 159 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,164 @@
1-
pg_replication:
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"
3-
master: true
4-
metrics:
5-
- lag:
6-
usage: "GAUGE"
7-
description: "Replication lag behind master in seconds"
8-
9-
pg_postmaster:
10-
query: "SELECT pg_postmaster_start_time as start_time_seconds from pg_postmaster_start_time()"
11-
master: true
12-
metrics:
13-
- start_time_seconds:
14-
usage: "GAUGE"
15-
description: "Time at which postmaster started"
16-
17-
pg_stat_user_tables:
18-
query: |
19-
SELECT
20-
current_database() datname,
21-
schemaname,
22-
relname,
23-
seq_scan,
24-
seq_tup_read,
25-
idx_scan,
26-
idx_tup_fetch,
27-
n_tup_ins,
28-
n_tup_upd,
29-
n_tup_del,
30-
n_tup_hot_upd,
31-
n_live_tup,
32-
n_dead_tup,
33-
n_mod_since_analyze,
34-
COALESCE(last_vacuum, '1970-01-01Z') as last_vacuum,
35-
COALESCE(last_autovacuum, '1970-01-01Z') as last_autovacuum,
36-
COALESCE(last_analyze, '1970-01-01Z') as last_analyze,
37-
COALESCE(last_autoanalyze, '1970-01-01Z') as last_autoanalyze,
38-
vacuum_count,
39-
autovacuum_count,
40-
analyze_count,
41-
autoanalyze_count
42-
FROM
43-
pg_stat_user_tables
44-
metrics:
45-
- datname:
46-
usage: "LABEL"
47-
description: "Name of current database"
48-
- schemaname:
49-
usage: "LABEL"
50-
description: "Name of the schema that this table is in"
51-
- relname:
52-
usage: "LABEL"
53-
description: "Name of this table"
54-
- seq_scan:
55-
usage: "COUNTER"
56-
description: "Number of sequential scans initiated on this table"
57-
- seq_tup_read:
58-
usage: "COUNTER"
59-
description: "Number of live rows fetched by sequential scans"
60-
- idx_scan:
61-
usage: "COUNTER"
62-
description: "Number of index scans initiated on this table"
63-
- idx_tup_fetch:
64-
usage: "COUNTER"
65-
description: "Number of live rows fetched by index scans"
66-
- n_tup_ins:
67-
usage: "COUNTER"
68-
description: "Number of rows inserted"
69-
- n_tup_upd:
70-
usage: "COUNTER"
71-
description: "Number of rows updated"
72-
- n_tup_del:
73-
usage: "COUNTER"
74-
description: "Number of rows deleted"
75-
- n_tup_hot_upd:
76-
usage: "COUNTER"
77-
description: "Number of rows HOT updated (i.e., with no separate index update required)"
78-
- n_live_tup:
79-
usage: "GAUGE"
80-
description: "Estimated number of live rows"
81-
- n_dead_tup:
82-
usage: "GAUGE"
83-
description: "Estimated number of dead rows"
84-
- n_mod_since_analyze:
85-
usage: "GAUGE"
86-
description: "Estimated number of rows changed since last analyze"
87-
- last_vacuum:
88-
usage: "GAUGE"
89-
description: "Last time at which this table was manually vacuumed (not counting VACUUM FULL)"
90-
- last_autovacuum:
91-
usage: "GAUGE"
92-
description: "Last time at which this table was vacuumed by the autovacuum daemon"
93-
- last_analyze:
94-
usage: "GAUGE"
95-
description: "Last time at which this table was manually analyzed"
96-
- last_autoanalyze:
97-
usage: "GAUGE"
98-
description: "Last time at which this table was analyzed by the autovacuum daemon"
99-
- vacuum_count:
100-
usage: "COUNTER"
101-
description: "Number of times this table has been manually vacuumed (not counting VACUUM FULL)"
102-
- autovacuum_count:
103-
usage: "COUNTER"
104-
description: "Number of times this table has been vacuumed by the autovacuum daemon"
105-
- analyze_count:
106-
usage: "COUNTER"
107-
description: "Number of times this table has been manually analyzed"
108-
- autoanalyze_count:
109-
usage: "COUNTER"
110-
description: "Number of times this table has been analyzed by the autovacuum daemon"
111-
112-
pg_statio_user_tables:
113-
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"
114-
metrics:
115-
- datname:
116-
usage: "LABEL"
117-
description: "Name of current database"
118-
- schemaname:
119-
usage: "LABEL"
120-
description: "Name of the schema that this table is in"
121-
- relname:
122-
usage: "LABEL"
123-
description: "Name of this table"
124-
- heap_blks_read:
125-
usage: "COUNTER"
126-
description: "Number of disk blocks read from this table"
127-
- heap_blks_hit:
128-
usage: "COUNTER"
129-
description: "Number of buffer hits in this table"
130-
- idx_blks_read:
131-
usage: "COUNTER"
132-
description: "Number of disk blocks read from all indexes on this table"
133-
- idx_blks_hit:
134-
usage: "COUNTER"
135-
description: "Number of buffer hits in all indexes on this table"
136-
- toast_blks_read:
137-
usage: "COUNTER"
138-
description: "Number of disk blocks read from this table's TOAST table (if any)"
139-
- toast_blks_hit:
140-
usage: "COUNTER"
141-
description: "Number of buffer hits in this table's TOAST table (if any)"
142-
- tidx_blks_read:
143-
usage: "COUNTER"
144-
description: "Number of disk blocks read from this table's TOAST table indexes (if any)"
145-
- tidx_blks_hit:
146-
usage: "COUNTER"
147-
description: "Number of buffer hits in this table's TOAST table indexes (if any)"
1+
#### Queries are commented due to PMM-8859
2+
#pg_replication:
3+
# 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"
4+
# master: true
5+
# metrics:
6+
# - lag:
7+
# usage: "GAUGE"
8+
# description: "Replication lag behind master in seconds"
1489

149-
pg_database:
150-
query: "SELECT pg_database.datname, pg_database_size(pg_database.datname) as size_bytes FROM pg_database"
151-
master: true
152-
cache_seconds: 30
153-
metrics:
154-
- datname:
155-
usage: "LABEL"
156-
description: "Name of the database"
157-
- size_bytes:
158-
usage: "GAUGE"
159-
description: "Disk space used by the database"
10+
#pg_postmaster:
11+
# query: "SELECT pg_postmaster_start_time as start_time_seconds from pg_postmaster_start_time()"
12+
# master: true
13+
# metrics:
14+
# - start_time_seconds:
15+
# usage: "GAUGE"
16+
# description: "Time at which postmaster started"
16017

18+
#pg_stat_user_tables:
19+
# query: |
20+
# SELECT
21+
# current_database() datname,
22+
# schemaname,
23+
# relname,
24+
# seq_scan,
25+
# seq_tup_read,
26+
# idx_scan,
27+
# idx_tup_fetch,
28+
# n_tup_ins,
29+
# n_tup_upd,
30+
# n_tup_del,
31+
# n_tup_hot_upd,
32+
# n_live_tup,
33+
# n_dead_tup,
34+
# n_mod_since_analyze,
35+
# COALESCE(last_vacuum, '1970-01-01Z') as last_vacuum,
36+
# COALESCE(last_autovacuum, '1970-01-01Z') as last_autovacuum,
37+
# COALESCE(last_analyze, '1970-01-01Z') as last_analyze,
38+
# COALESCE(last_autoanalyze, '1970-01-01Z') as last_autoanalyze,
39+
# vacuum_count,
40+
# autovacuum_count,
41+
# analyze_count,
42+
# autoanalyze_count
43+
# FROM
44+
# pg_stat_user_tables
45+
# metrics:
46+
# - datname:
47+
# usage: "LABEL"
48+
# description: "Name of current database"
49+
# - schemaname:
50+
# usage: "LABEL"
51+
# description: "Name of the schema that this table is in"
52+
# - relname:
53+
# usage: "LABEL"
54+
# description: "Name of this table"
55+
# - seq_scan:
56+
# usage: "COUNTER"
57+
# description: "Number of sequential scans initiated on this table"
58+
# - seq_tup_read:
59+
# usage: "COUNTER"
60+
# description: "Number of live rows fetched by sequential scans"
61+
# - idx_scan:
62+
# usage: "COUNTER"
63+
# description: "Number of index scans initiated on this table"
64+
# - idx_tup_fetch:
65+
# usage: "COUNTER"
66+
# description: "Number of live rows fetched by index scans"
67+
# - n_tup_ins:
68+
# usage: "COUNTER"
69+
# description: "Number of rows inserted"
70+
# - n_tup_upd:
71+
# usage: "COUNTER"
72+
# description: "Number of rows updated"
73+
# - n_tup_del:
74+
# usage: "COUNTER"
75+
# description: "Number of rows deleted"
76+
# - n_tup_hot_upd:
77+
# usage: "COUNTER"
78+
# description: "Number of rows HOT updated (i.e., with no separate index update required)"
79+
# - n_live_tup:
80+
# usage: "GAUGE"
81+
# description: "Estimated number of live rows"
82+
# - n_dead_tup:
83+
# usage: "GAUGE"
84+
# description: "Estimated number of dead rows"
85+
# - n_mod_since_analyze:
86+
# usage: "GAUGE"
87+
# description: "Estimated number of rows changed since last analyze"
88+
# - last_vacuum:
89+
# usage: "GAUGE"
90+
# description: "Last time at which this table was manually vacuumed (not counting VACUUM FULL)"
91+
# - last_autovacuum:
92+
# usage: "GAUGE"
93+
# description: "Last time at which this table was vacuumed by the autovacuum daemon"
94+
# - last_analyze:
95+
# usage: "GAUGE"
96+
# description: "Last time at which this table was manually analyzed"
97+
# - last_autoanalyze:
98+
# usage: "GAUGE"
99+
# description: "Last time at which this table was analyzed by the autovacuum daemon"
100+
# - vacuum_count:
101+
# usage: "COUNTER"
102+
# description: "Number of times this table has been manually vacuumed (not counting VACUUM FULL)"
103+
# - autovacuum_count:
104+
# usage: "COUNTER"
105+
# description: "Number of times this table has been vacuumed by the autovacuum daemon"
106+
# - analyze_count:
107+
# usage: "COUNTER"
108+
# description: "Number of times this table has been manually analyzed"
109+
# - autoanalyze_count:
110+
# usage: "COUNTER"
111+
# description: "Number of times this table has been analyzed by the autovacuum daemon"
112+
#
113+
#pg_statio_user_tables:
114+
# 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"
115+
# metrics:
116+
# - datname:
117+
# usage: "LABEL"
118+
# description: "Name of current database"
119+
# - schemaname:
120+
# usage: "LABEL"
121+
# description: "Name of the schema that this table is in"
122+
# - relname:
123+
# usage: "LABEL"
124+
# description: "Name of this table"
125+
# - heap_blks_read:
126+
# usage: "COUNTER"
127+
# description: "Number of disk blocks read from this table"
128+
# - heap_blks_hit:
129+
# usage: "COUNTER"
130+
# description: "Number of buffer hits in this table"
131+
# - idx_blks_read:
132+
# usage: "COUNTER"
133+
# description: "Number of disk blocks read from all indexes on this table"
134+
# - idx_blks_hit:
135+
# usage: "COUNTER"
136+
# description: "Number of buffer hits in all indexes on this table"
137+
# - toast_blks_read:
138+
# usage: "COUNTER"
139+
# description: "Number of disk blocks read from this table's TOAST table (if any)"
140+
# - toast_blks_hit:
141+
# usage: "COUNTER"
142+
# description: "Number of buffer hits in this table's TOAST table (if any)"
143+
# - tidx_blks_read:
144+
# usage: "COUNTER"
145+
# description: "Number of disk blocks read from this table's TOAST table indexes (if any)"
146+
# - tidx_blks_hit:
147+
# usage: "COUNTER"
148+
# description: "Number of buffer hits in this table's TOAST table indexes (if any)"
149+
#
150+
#pg_database:
151+
# query: "SELECT pg_database.datname, pg_database_size(pg_database.datname) as size_bytes FROM pg_database"
152+
# master: true
153+
# cache_seconds: 30
154+
# metrics:
155+
# - datname:
156+
# usage: "LABEL"
157+
# description: "Name of the database"
158+
# - size_bytes:
159+
# usage: "GAUGE"
160+
# description: "Disk space used by the database"
161+
####
161162
#pg_stat_statements:
162163
# query: "SELECT t2.rolname, t3.datname, queryid, calls, total_time / 1000 as total_time_seconds, min_time / 1000 as min_time_seconds, max_time / 1000 as max_time_seconds, mean_time / 1000 as mean_time_seconds, stddev_time / 1000 as stddev_time_seconds, rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, local_blks_hit, local_blks_read, local_blks_dirtied, local_blks_written, temp_blks_read, temp_blks_written, blk_read_time / 1000 as blk_read_time_seconds, blk_write_time / 1000 as blk_write_time_seconds FROM pg_stat_statements t1 JOIN pg_roles t2 ON (t1.userid=t2.oid) JOIN pg_database t3 ON (t1.dbid=t3.oid) WHERE t2.rolname != 'rdsadmin'"
163164
# master: true

0 commit comments

Comments
 (0)