Hi,
“I have attempted to create a custom query named vaid_pg_replication to identify replication lag on postgres.
I have added the query to pmm client version pmm2-client-2.35 :
-rw-r–r-- 1 root root 1257 Jun 2 18:05 /usr/local/percona/pmm2/collectors/custom-queries/postgresql/medium-resolution/my_query.yml.”
$ cat /usr/local/percona/pmm2/collectors/custom-queries/postgresql/medium-resolution/my_query.yml
vaid_pg_replication :
query : "SELECT application_name,client_addr,state, \\
(sent_offset - (replay_offset - (sent_xlog - replay_xlog) * 255 * 16 ^ 6 ))::text AS byte_lag \\
FROM (SELECT \\
application_name,client_addr,state,sync_state,sent_lsn,write_lsn,replay_lsn, \\
('x' || lpad(split_part(sent_lsn::text, '/', 1), 8, '0'))::bit(32)::bigint AS sent_xlog, \\
('x' || lpad(split_part(replay_lsn::text, '/', 1), 8, '0'))::bit(32)::bigint AS replay_xlog, \\
('x' || lpad(split_part(sent_lsn::text, '/', 2), 8, '0'))::bit(32)::bigint AS sent_offset, \\
('x' || lpad(split_part(replay_lsn::text, '/', 2), 8, '0'))::bit(32)::bigint AS replay_offset \\
FROM pg_stat_replication) \\
AS s"
metrics:
- application_name:
usage: "LABEL"
description: "Node Name"
- client_addr:
usage: "LABEL"
description: "Node IP address"
- state:
usage: "LABEL"
description: "State of the connection"
- byte_lag:
usage: "GAUGE"
description: "Replication Lag behind Master in second"
However, I cannot find the custom query in the dashboard dropdown under advanced data exploration. Have I overlooked something
Thank