Logical data replication is only supported in CockroachDB self-hosted clusters.
SHOW LOGICAL REPLICATION JOBSin the SQL shell to view a list of LDR jobs on the cluster.- The on the DB Console to view metrics at the cluster level.
- Prometheus and Alertmanager to track and alert on LDR metrics.
- Metrics export with Datadog.
- Metrics labels to view metrics at the job level.
- The history retention job on the source cluster, which runs while the LDR job is active to protect changes in the table from until they have been applied to the destination cluster. The history retention job is viewable in the DB Console or with . Any manual changes to the history retention job could disrupt the LDR job.
- The
logical replicationjob on the destination cluster. You can view the status of this job in the SQL shell withSHOW LOGICAL REPLICATION JOBSand the DB Console Jobs page.
SQL Shell
In the destination cluster’s SQL shell, you can querySHOW LOGICAL REPLICATION JOBS to view the LDR jobs running on the cluster:
WITH details option:
Responses
| Field | Response |
|---|---|
job\_id | The job’s ID. Use with , , , . |
status | The job’s current state. Possible values: pending, paused, pause-requested, failed, succeeded, canceled, cancel-requested, running, retry-running, retry-reverting, reverting, revert-failed. Refer to for a description of each status. |
tables | The fully qualified name of the table(s) that are part of the LDR job. |
replicated\_time | The latest at which the destination cluster has consistent data. This time advances automatically as long as the LDR job proceeds without error. replicated\_time is updated periodically (every 30s). |
replication\_start\_time | The start time of the LDR job. |
conflict\_resolution\_type | The type of : LWW last write wins. |
command | Description of the job including the replicating table(s) and the cluster connections. |
Recommended LDR metrics to track
- Replication latency: The commit-to-commit replication latency, which is tracked from when a row is committed on the source cluster, to when it is applied on the destination cluster. An LDR commit is when the job either applies a row successfully to the destination cluster or adds a row to the .
logical_replication.commit_latency-p50logical_replication.commit_latency-p99
- Replication lag: How far behind the source cluster is from the destination cluster at a specific point in time. The replication lag is equivalent to during a disaster. Calculate the replication lag with this metric. For example,
time.now() - replicated_time_seconds.logical_replication.replicated_time_seconds
- Row updates applied: These metrics indicate whether the destination cluster is actively receiving and applying data from the source cluster.
logical_replication.events_ingestedlogical_replication.events_dlqed
DB Console
In the DB Console, you can use:- The for LDR to view metrics for the job on the destination cluster.
- The to view the history retention job on the source cluster and the LDR job on the destination cluster
Metrics dashboard
You can use the of the destination cluster to monitor the following metric graphs at the cluster level:- Replication latency
- Replication lag
- Row updates applied
- Logical bytes received
- Batch application processing time: 50th percentile
- Batch application processing time: 99th percentile
- DLQ causes
- Retry queue size
Jobs page
On the , select:- The Replication Producer in the source cluster’s DB Console to view the history retention job.
- The Logical Replication Ingestion job in the destination cluster’s DB Console. When you start LDR, the Logical Replication Ingestion job will show a bar that tracks the initial scan progress of the source table’s existing data.
Monitoring and alerting
Prometheus
You can use Prometheus and Alertmanager to track and alert on LDR metrics. Refer to the tutorial for steps to set up Prometheus.Metrics labels
To view metrics at the job level, you can use thelabel option when you start LDR to add a metrics label to the LDR job. This enables export, which are Prometheus time series with extra labels. You can track the following metrics for an LDR job with labels:
logical_replication.catchup_ranges_by_labellogical_replication.events_dlqed_by_labellogical_replication.events_ingested_by_labellogical_replication.replicated_time_by_labellogical_replication.scanning_ranges_by_label
label option:

