Skip to content

Commit 64f5d9a

Browse files
committed
Document -extend.query-path in README. Add more examples to queries.yaml.
1 parent fc3a14f commit 64f5d9a

File tree

2 files changed

+101
-3
lines changed

2 files changed

+101
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ for l in StringIO(x):
6565
Adjust the value of the resultant prometheus value type appropriately. This helps build
6666
rich self-documenting metrics for the exporter.
6767

68+
### Adding new metrics via a config file
69+
70+
The -extend.query-path command-line argument specifies a YAML file containing additional queries to run.
71+
Some examples are provided in [queries.yaml](queries.yaml).
6872

6973
### Running as non-superuser
7074

queries.yaml

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,100 @@
11
pg_replication:
2-
query: 'SELECT EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))::INT as lag'
2+
query: "SELECT EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))::INT as lag"
33
metrics:
44
- lag:
5-
usage: 'GAUGE'
6-
description: 'Replication lag behind master in seconds'
5+
usage: "GAUGE"
6+
description: "Replication lag behind master in seconds"
7+
8+
pg_postmaster:
9+
query: "SELECT pg_postmaster_start_time as start_time_seconds from pg_postmaster_start_time()"
10+
metrics:
11+
- start_time_seconds:
12+
usage: "GAUGE"
13+
description: "Time at which postmaster started"
14+
15+
pg_settings_shared_buffers:
16+
query: "SELECT 8192*setting as bytes from pg_settings where name = 'shared_buffers'"
17+
metrics:
18+
- bytes:
19+
usage: "GAUGE"
20+
description: "Size of shared_buffers"
21+
22+
pg_settings_checkpoint:
23+
query: "select (select setting::int from pg_settings where name = 'checkpoint_segments') as segments, (select setting::int from pg_settings where name = 'checkpoint_timeout') as timeout_seconds, (select setting::float from pg_settings where name = 'checkpoint_completion_target') as completion_target"
24+
metrics:
25+
- segments:
26+
usage: "GAUGE"
27+
description: "Number of checkpoint segments"
28+
- timeout_seconds:
29+
usage: "GAUGE"
30+
description: "Checkpoint timeout in seconds"
31+
- completion_target:
32+
usage: "GAUGE"
33+
description: "Checkpoint completion target, ranging from 0 to 1"
34+
35+
pg_stat_user_tables:
36+
query: "SELECT 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, last_vacuum, last_autovacuum, last_analyze, last_autoanalyze, vacuum_count, autovacuum_count, analyze_count, autoanalyze_count FROM pg_stat_user_tables"
37+
metrics:
38+
- schemaname:
39+
usage: "LABEL"
40+
description: "Name of the schema that this table is in"
41+
- relname:
42+
usage: "LABEL"
43+
description: "Name of this table"
44+
- seq_scan:
45+
usage: "COUNTER"
46+
description: "Number of sequential scans initiated on this table"
47+
- seq_tup_read:
48+
usage: "COUNTER"
49+
description: "Number of live rows fetched by sequential scans"
50+
- idx_scan:
51+
usage: "COUNTER"
52+
description: "Number of index scans initiated on this table"
53+
- idx_tup_fetch:
54+
usage: "COUNTER"
55+
description: "Number of live rows fetched by index scans"
56+
- n_tup_ins:
57+
usage: "COUNTER"
58+
description: "Number of rows inserted"
59+
- n_tup_upd:
60+
usage: "COUNTER"
61+
description: "Number of rows updated"
62+
- n_tup_del:
63+
usage: "COUNTER"
64+
description: "Number of rows deleted"
65+
- n_tup_hot_upd:
66+
usage: "COUNTER"
67+
description: "Number of rows HOT updated (i.e., with no separate index update required)"
68+
- n_live_tup:
69+
usage: "GAUGE"
70+
description: "Estimated number of live rows"
71+
- n_dead_tup:
72+
usage: "GAUGE"
73+
description: "Estimated number of dead rows"
74+
- n_mod_since_analyze:
75+
usage: "GAUGE"
76+
description: "Estimated number of rows changed since last analyze"
77+
- last_vacuum:
78+
usage: "GAUGE"
79+
description: "Last time at which this table was manually vacuumed (not counting VACUUM FULL)"
80+
- last_autovacuum:
81+
usage: "GAUGE"
82+
description: "Last time at which this table was vacuumed by the autovacuum daemon"
83+
- last_analyze:
84+
usage: "GAUGE"
85+
description: "Last time at which this table was manually analyzed"
86+
- last_autoanalyze:
87+
usage: "GAUGE"
88+
description: "Last time at which this table was analyzed by the autovacuum daemon"
89+
- vacuum_count:
90+
usage: "COUNTER"
91+
description: "Number of times this table has been manually vacuumed (not counting VACUUM FULL)"
92+
- autovacuum_count:
93+
usage: "COUNTER"
94+
description: "Number of times this table has been vacuumed by the autovacuum daemon"
95+
- analyze_count:
96+
usage: "COUNTER"
97+
description: "Number of times this table has been manually analyzed"
98+
- autoanalyze_count:
99+
usage: "COUNTER"
100+
description: "Number of times this table has been analyzed by the autovacuum daemon"

0 commit comments

Comments
 (0)