Python xdcr - get replica status

Im following the documation for xdcr statistics api:

https://dhttps://docs.couchbase.com/server/current/rest-api/rest-xdcr-statistics.htmlcs.couchbase.com/server/current/rest-api/rest-xdcr-statistics.html

I’d like to write functions which allow monitor replica satatus:

1.Check if replica exists for source_bucket–>target_bucket
far as i check , it seems I must have the replica UUID in ordet to check the status of
existing replica (either running/paused ) ,

i.e:

curl -X POST -u Administrator:Administrator http://aaaa:8091/settings/replications/7bbc6033acdd8922079eef52c0f83559%2Fsource_bucket%2target_bucket

it seems i first need to get all replica under the cluster ,
meaning:

curl -u Administrator:Administrator -v -X GET  http://aaaa:8091/pools/default/tasks 

then i can extract the UUID
and continue from there

2.Number of files replica sync/copy :

following:
https://docs.couchbase.com/server/current/rest-api/rest-xdcr-statistics.html

As test

curl -u  Administrator:Administrator http://123.123.123.23:8091/pools/default/buckets/com.amdocs.digital.ms.partymanagementsubdomain/stats/replications%2F7bbc6033acdd8922079eef52c0f83559%2Fcompartymanagementsubdomain%2Ftarget_bucket%2Fdocs_written

How could i know how many record replicate written ?
it returns some unclear information:
image

To be clear - when you say “replica”, I think you’re talking about “replication”.

You are technically correct. That is one way to go about it. You essentially are getting the “replication ID”, which is composed of

Where the / is replaced by %2F.

The “docs_written” stats is a stat that remains cumulative, meaning that each sampling window, it’ll return the last known stats back to you.

For example, this bash function’s comment shows you what you are looking at:

And “getStats” function essentially is doing what you are trying to do - parse the record and find the last stats in the last window:

Thanks Neil ,

I have some doubts for the docs_written and i explain ,

On source DB:
select count(*) from source_bucket:
22
On Target DB :
flushing the bucket

Delete existing replication and re create it with the following configuration :

    def _CreateXDCRReplica(self):
        print("creating replica")
        data = {'fromBucket': self.src_bucket_name,               
                'toBucket': self.trg_bucket_name,
                 'toCluster': self.cluster_name,
                'replicationType': '**continuous**',
                'enableCompression': '1'
                 }
        print(data,"\n",self.src_http_path + "/controller/createReplication")

        try:
          response = requests.post(self.src_http_path + "/controller/createReplication", data=data, auth=(self.SOURCE_USER, self.SOURCE_PASSWORD))
          response.raise_for_status()
          
                  
        except requests.exception

Executing

curl -u  Administrator:Administrator http://123.123.123.23:8091/pools/default/buckets/com.amdocs.digital.ms.partymanagementsubdomain/stats/replications%2F7bbc6033acdd8922079eef52c0f83559%2Fsource_bucket%2Ftarget_bucket%2Fdocs_written

Getting :

Expected :
22

actual:
select count(*) from target_bucket
21

strangely 1 is missing , what could be the reason ?
Update :

I ran some bucket comparison and found the xdcr replication skipping document naming
“_txn:client-record” :{}
Not sure what this documents but it doesn’t look like something i need to copy.

Running :

curl -u  Administrator:Administrator http://123.123.123.23:8091/pools/default/buckets/com.amdocs.digital.ms.partymanagementsubdomain/stats/replications%2F7bbc6033acdd8922079eef52c0f83559%2Fsource_bucket%2Ftarget_bucket%2Fdocs_written

image

Also last object shows 45 …so I guess i missing something.
maybe i didn’t understand how it works ,

I’m trying to find useful way for validating the results of running replications ,
number of document written and failure .
I guess i could run some count query but I would expect from xdcr statstics provide such basic information natively.

Not sure if the question was clear ,
I’m trying to find a way to monitor the replication status for:
docs written
docs failed
docs updated

as mention , the return json of the docs_written stat return somethings unclear.