1
+ pg_custom_replication_slots :
2
+ query : |
3
+ SELECT
4
+ slot_name,
5
+ plugin,
6
+ slot_type,
7
+ active,
8
+ restart_lsn::pg_lsn - '0/0'::pg_lsn AS restart_lsn_bytes,
9
+ confirmed_flush_lsn::pg_lsn - '0/0'::pg_lsn AS confirmed_flush_lsn_bytes
10
+ FROM pg_replication_slots;
11
+ metrics :
12
+ - slot_name :
13
+ usage : " LABEL"
14
+ description : " Name of the replication slot."
15
+ - plugin :
16
+ usage : " LABEL"
17
+ description : " Plugin associated with the replication slot."
18
+ - slot_type :
19
+ usage : " LABEL"
20
+ description : " Type of replication slot (e.g., logical, physical)."
21
+ - active :
22
+ usage : " GAUGE"
23
+ description : " Whether the slot is active (1 for active, 0 for inactive)."
24
+ - restart_lsn_bytes :
25
+ usage : " GAUGE"
26
+ description : " Restart LSN in bytes for the replication slot."
27
+ - confirmed_flush_lsn_bytes :
28
+ usage : " GAUGE"
29
+ description : " Confirmed flush LSN in bytes for the replication slot."
30
+
31
+ pg_custom_stat_wal_receiver :
32
+ query : |
33
+ SELECT
34
+ status,
35
+ sender_host AS primary_host,
36
+ written_lsn::pg_lsn - '0/0'::pg_lsn AS written_lsn_bytes,
37
+ latest_end_lsn::pg_lsn - '0/0'::pg_lsn AS latest_end_lsn_bytes,
38
+ latest_end_lsn::pg_lsn - pg_last_wal_replay_lsn()::pg_lsn AS lag_bytes,
39
+ EXTRACT(EPOCH FROM latest_end_time) AS latest_end_time_seconds,
40
+ EXTRACT(EPOCH FROM (now() - latest_end_time)) AS lag_time_seconds,
41
+ EXTRACT(EPOCH FROM last_msg_send_time) AS last_msg_send_time_seconds,
42
+ EXTRACT(EPOCH FROM last_msg_receipt_time) AS last_msg_receipt_time_seconds
43
+ FROM pg_stat_wal_receiver;
44
+ metrics :
45
+ - status :
46
+ usage : " LABEL"
47
+ description : " WAL receiver's status (e.g., streaming, stopped)."
48
+ - primary_host :
49
+ usage : " LABEL"
50
+ description : " Primary instance host."
51
+ - written_lsn_bytes :
52
+ usage : " GAUGE"
53
+ description : " Bytes of WAL data written by the WAL receiver."
54
+ - latest_end_lsn_bytes :
55
+ usage : " GAUGE"
56
+ description : " Bytes of WAL data received by the WAL receiver."
57
+ - lag_bytes :
58
+ usage : " GAUGE"
59
+ description : " WAL replication lag in bytes."
60
+ - latest_end_time_seconds :
61
+ usage : " GAUGE"
62
+ description : " Timestamp of the latest received WAL segment."
63
+ - lag_time_seconds :
64
+ usage : " GAUGE"
65
+ description : " Replication lag time (difference between now and latest_end_time)."
66
+ - last_msg_send_time_seconds :
67
+ usage : " GAUGE"
68
+ description : " Timestamp of the last message sent in seconds since the epoch."
69
+ - last_msg_receipt_time_seconds :
70
+ usage : " GAUGE"
71
+ description : " Timestamp of the last message received in seconds since the epoch."
72
+
73
+
74
+ pg_custom_database_size_custom :
75
+ query : " SELECT pg_database.datname, pg_database_size(pg_database.datname) as bytes FROM pg_database"
76
+ master : false
77
+ cache_seconds : 30
78
+ metrics :
79
+ - datname :
80
+ usage : " LABEL"
81
+ description : " Name of the database"
82
+ - bytes :
83
+ usage : " GAUGE"
84
+ description : " Disk space used by the database"
85
+
86
+ pg_custom_replication_wal :
87
+ query : |
88
+ SELECT
89
+ pg_last_wal_receive_lsn() AS received_lsn,
90
+ pg_last_wal_replay_lsn() AS replayed_lsn,
91
+ pg_current_wal_lsn() AS current_lsn,
92
+ pg_current_wal_lsn() - pg_last_wal_replay_lsn() AS lag_bytes;
93
+ metrics :
94
+ - received_lsn :
95
+ usage : " GAUGE"
96
+ description : " Last WAL location received by the standby server."
97
+ - replayed_lsn :
98
+ usage : " GAUGE"
99
+ description : " Last WAL location replayed by the standby server."
100
+ - current_lsn :
101
+ usage : " GAUGE"
102
+ description : " Current WAL location on the primary server."
103
+ - lag_bytes :
104
+ usage : " GAUGE"
105
+ description : " Current WAL replication lag in bytes."
106
+
107
+ pg_custom_stat_replication :
108
+ query : |
109
+ SELECT
110
+ pid,
111
+ usename,
112
+ application_name,
113
+ client_addr,
114
+ state,
115
+ flush_lsn::pg_lsn - '0/0'::pg_lsn AS flush_lsn_bytes,
116
+ write_lsn::pg_lsn - '0/0'::pg_lsn AS write_lsn_bytes,
117
+ replay_lsn::pg_lsn - '0/0'::pg_lsn AS replay_lsn_bytes,
118
+ EXTRACT(EPOCH FROM write_lag) AS write_lag_seconds,
119
+ EXTRACT(EPOCH FROM flush_lag) AS flush_lag_seconds,
120
+ EXTRACT(EPOCH FROM replay_lag) AS replay_lag_seconds,
121
+ sync_state
122
+ FROM pg_stat_replication;
123
+ metrics :
124
+ - pid :
125
+ usage : " LABEL"
126
+ description : " Process ID of the replication connection."
127
+ - usename :
128
+ usage : " LABEL"
129
+ description : " Name of the user connected for replication."
130
+ - application_name :
131
+ usage : " LABEL"
132
+ description : " Application name of the client."
133
+ - client_addr :
134
+ usage : " LABEL"
135
+ description : " Client IP address."
136
+ - state :
137
+ usage : " LABEL"
138
+ description : " State of the replication connection."
139
+ - flush_lsn_bytes :
140
+ usage : " GAUGE"
141
+ description : " Flush LSN in bytes."
142
+ - write_lsn_bytes :
143
+ usage : " GAUGE"
144
+ description : " Write LSN in bytes."
145
+ - replay_lsn_bytes :
146
+ usage : " GAUGE"
147
+ description : " Replay LSN in bytes."
148
+ - write_lag_seconds :
149
+ usage : " GAUGE"
150
+ description : " Write lag in seconds."
151
+ - flush_lag_seconds :
152
+ usage : " GAUGE"
153
+ description : " Flush lag in seconds."
154
+ - replay_lag_seconds :
155
+ usage : " GAUGE"
156
+ description : " Replay lag in seconds."
157
+ - sync_state :
158
+ usage : " LABEL"
159
+ description : " Synchronization state (e.g., async, sync)."
160
+
161
+ pg_custom_stat_activity_walsender :
162
+ query : |
163
+ SELECT
164
+ pid,
165
+ usename,
166
+ application_name,
167
+ client_addr,
168
+ extract(epoch from backend_start) AS backend_start_unix,
169
+ state
170
+ FROM pg_stat_activity
171
+ WHERE backend_type = 'walsender';
172
+ metrics :
173
+ - pid :
174
+ usage : " GAUGE"
175
+ description : " Process ID of the WAL sender"
176
+ - usename :
177
+ usage : " LABEL"
178
+ description : " User name associated with the WAL sender"
179
+ - application_name :
180
+ usage : " LABEL"
181
+ description : " Application name of the WAL sender"
182
+ - client_addr :
183
+ usage : " LABEL"
184
+ description : " Client IP address of the WAL sender"
185
+ - backend_start_unix :
186
+ usage : " GAUGE"
187
+ description : " Start time of the backend as a Unix timestamp"
188
+ - state :
189
+ usage : " LABEL"
190
+ description : " Current state of the WAL sender process"
191
+
192
+ pg_custom_stat_subscription :
193
+ query : " SELECT subid, subname, pid, received_lsn, last_msg_send_time, last_msg_receipt_time FROM pg_stat_subscription;"
194
+ metrics :
195
+ - subid :
196
+ usage : " LABEL"
197
+ description : " Subscription ID"
198
+ - subname :
199
+ usage : " LABEL"
200
+ description : " Subscription Name"
201
+ - pid :
202
+ usage : " GAUGE"
203
+ description : " Process ID of subscription worker"
204
+ - received_lsn :
205
+ usage : " GAUGE"
206
+ description : " Last received LSN"
207
+ - last_msg_send_time :
208
+ usage : " GAUGE"
209
+ description : " Last message sent time"
210
+ - last_msg_receipt_time :
211
+ usage : " GAUGE"
212
+ description : " Last message receipt time"
213
+
214
+ pg_custom_publication :
215
+ query : " SELECT pubname, puballtables, pubinsert, pubupdate, pubdelete FROM pg_publication;"
216
+ metrics :
217
+ - pubname :
218
+ usage : " LABEL"
219
+ description : " Publication Name"
220
+ - puballtables :
221
+ usage : " GAUGE"
222
+ description : " All tables published"
223
+ - pubinsert :
224
+ usage : " GAUGE"
225
+ description : " Insert operations published"
226
+ - pubupdate :
227
+ usage : " GAUGE"
228
+ description : " Update operations published"
229
+ - pubdelete :
230
+ usage : " GAUGE"
231
+ description : " Delete operations published"
0 commit comments