Skip to main content

Monitoring Logical Replication

Jo aapde replication use karta hoi to aapde aapda cluster nu proper monitoring karvu j joie.

Replication ne monitor karva nu best way 6e pg_stat_replication table. aa table khub jaruri information store kari rakhe 6e.

Aapde monitoring vise janye aena pehla ae janvu jaruri 6e k monitoring hammesa master/publisher ma hoi 6e.

Chalo have joie k pg_stat_replication ma kai prakar no data store thai 6e.

proper values ne jova mate pehla to extended view ma switch thai jao.

\x

have pg_stat_replication table ma jovo.

- [RECORD 1] ---------------------------
pid | 1919
usesysid | 10
usename | ubuntumaster
application_name | mysub
client_addr | 127.0.0.1
client_hostname |
client_port | 48652
backend_start | 2025-11-18 02:41:05.439343+00
backend_xmin |
state | streaming
sent_lsn | 0/19D41E8
write_lsn | 0/19D41E8
flush_lsn | 0/19D41E8
replay_lsn | 0/19D41E8
write_lag |
flush_lag |
replay_lag |
sync_priority | 0
sync_state | async
reply_time | 2025-11-18 03:36:34.872353+00

replication lag amount ek important matrics 6e. aa seconds ma hoi 6e. Jo aapde time intervals ma lag ne measure karvo hoi to, _lag thi end thati columns no data jovo. for example, ahi aapde joi sakie 6ie write_lag, flush_lag and replay_lag.

haal ma ahi records ma koi data dekhato nathi pan usually ahi aapde data ne seconds or minutes ma joi sakie 6ie.

Jo replication progress ma 6e thva proper work kare 6e to aa lag samanya rite bau nano, means ghani vakhat mili seconds ma hoi 6e.

write_lag represent kare 6e primary ma commit thaya no ane replica/standby vacche no elapsed time. pan aahiya haju flash nathi thyo. (changes na logs primary mathi nikdi nathi gya) flash_lag represent kare 6e write_lag time + flash thai java no. replay_lag represent kare 6e flash_lag + ae changes replica/standby ma replay thai apply thai javano.

in short, replay_lag ae, ae time 6e jyare master no data replica ma available thai gyo 6e. to jo tamare koi alarm set karva 6e like aana thi vadhare time na hovo joie to aa parameter upar rakhi sakay.

aapdi pase banne primary and replica vacche bytes vacche nu distance measure karva mate bhi metrics 6e. jem k sent_lsn, write_lsn, flush_lsn and replay_lsn. aa ek alag prakar ni data type ma present hoi 6e.

Aa sivay aapde joi sakie 6ie k kai kai publication aapda server ma active 6e. ae jova mate \dRp no use kari sakay ane subscription jova mate \dRs no use kari sakay.