> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# MOLT Replicator Metrics

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

<InternalLink path="molt-replicator">MOLT Replicator</InternalLink> exposes Prometheus metrics at each stage of the [replication pipeline](#replication-pipeline). When using Replicator to perform <InternalLink path="molt-replicator#forward-replication-after-initial-load">forward replication</InternalLink> or <InternalLink path="molt-replicator#failback-replication">failback</InternalLink>, you should monitor the health of each relevant pipeline stage to quickly detect issues.

This page describes and provides usage guidelines for Replicator metrics, according to the replication source:

* PostgreSQL
* MySQL
* Oracle
* CockroachDB (during <InternalLink path="molt-replicator#failback-replication">failback</InternalLink>)

<Tip>
  Some of the contents of this page are specific to your source database (PostgreSQL, MySQL, Oracle, or CockroachDB for failback). Select your source using the dropdown at the top right of this page.
</Tip>

## Replication pipeline

<InternalLink path="molt-replicator">MOLT Replicator</InternalLink> replicates data as a pipeline of change events that travel from the source database to the target database where changes are applied. The Replicator pipeline consists of four stages:

* [**Source read**](#source-read): Connects Replicator to the source database and captures changes via logical replication (PostgreSQL, MySQL), LogMiner (Oracle), or <InternalLink version="stable" path="changefeed-messages">changefeed messages</InternalLink> (CockroachDB).

<View title="PostgreSQL">
  <Tip>
    The instructions in this section are specific to **PostgreSQL** source databases. To see instructions for other source database types, select a different option from the dropdown at the top right of this page.
  </Tip>

  * **Staging**: Buffers mutations for ordered processing and crash recovery.

  * [**Core sequencer**](#core-sequencer): Processes staged mutations, maintains ordering guarantees, and coordinates transaction application.

  * [**Target apply**](#target-apply): Applies mutations to the target database.

  ## Set up metrics

  Enable Replicator metrics by specifying the <InternalLink path="replicator-flags">`--metricsAddr`</InternalLink> flag with a port (or `host:port`) when you start Replicator. This exposes Replicator metrics at `http://{host}:{port}/_/varz`. For example, the following command exposes metrics on port `30005`:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  replicator start \
  --targetConn $TARGET \
  --stagingConn $STAGING \
  --metricsAddr :30005
  ...
  ```

  To collect Replicator metrics, set up [Prometheus](https://prometheus.io/) to scrape the [Replicator metrics endpoint](#metrics-endpoints). To [visualize Replicator metrics](#visualize-metrics), use [Grafana](https://grafana.com/) to create dashboards.

  ## Metrics endpoints

  The following endpoints are available when you [enable Replicator metrics](#set-up-metrics):

  | Endpoint        | Description                               |
  | --------------- | ----------------------------------------- |
  | `/_/varz`       | Prometheus metrics endpoint.              |
  | `/_/diag`       | Structured diagnostic information (JSON). |
  | `/_/healthz`    | Health check endpoint.                    |
  | `/debug/pprof/` | Go pprof handlers for profiling.          |

  For example, to view the current snapshot of Replicator metrics on port `30005`, open `http://localhost:30005/_/varz` in a browser. To track metrics over time and create visualizations, use Prometheus and Grafana as described in [Set up metrics](#set-up-metrics).

  To check Replicator health:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  curl http://localhost:30005/_/healthz
  ```

  ```
  OK
  ```

  ### Visualize metrics

  Use the Replicator Grafana dashboard <InternalLink path="molt-replicator-installation">bundled with your binary</InternalLink> (`replicator_grafana_dashboard.json`) to visualize metrics. The bundled dashboard matches your binary version. Alternatively, you can download the [latest dashboard](https://replicator.cockroachdb.com/replicator_grafana_dashboard.json).

  ## Overall replication metrics

  ### High-level performance metrics

  Monitor the following metrics to track the overall health of the [replication pipeline](#replication-pipeline):

  * <a id="core-source-lag-seconds" />`core_source_lag_seconds`
    * Description: Age of the most recently received checkpoint. This represents the time from source commit to `COMMIT` event processing.
    * Interpretation: If consistently increasing, Replicator is falling behind in reading source changes, and cannot keep pace with database changes.
  * <a id="target-apply-mutation-age-seconds" />`target_apply_mutation_age_seconds`
    * Description: End-to-end replication lag per mutation from source commit to target apply. Measures the difference between current wall time and the mutation's <InternalLink version="stable" path="architecture/storage-layer#mvcc">MVCC timestamp</InternalLink>.
    * Interpretation: Higher values mean that older mutations are being applied, and indicate end-to-end pipeline delays. Compare across tables to find bottlenecks.
  * <a id="target-apply-queue-utilization-percent" />`target_apply_queue_utilization_percent`
    * Description: Percentage of target apply queue capacity utilization.
    * Interpretation: Values above 90 percent indicate severe backpressure throughout the pipeline, and potential data processing delays. Increase <InternalLink path="replicator-flags#target-apply-queue-size">`--targetApplyQueueSize`</InternalLink> or investigate target database performance.

  ### Replication lag

  Monitor the following metrics to track end-to-end replication lag:

  * <a id="source-commit-to-apply-lag-seconds" />`source_commit_to_apply_lag_seconds`
    * Description: Time delta between writing a mutation to the source and writing it to the target.
    * Interpretation: This may indicate the duration of a <InternalLink path="migration-considerations-replication#permissible-downtime">minimum downtime window</InternalLink> due to drainage. Low values (seconds or hundreds of milliseconds) would allow for minimal downtime on cutover.

  * <a id="target-apply-transaction-lag-seconds" />`target_apply_transaction_lag_seconds`
    * Description: Age of the transaction applied to the target table, measuring time from source commit to target apply.
    * Interpretation: Consistently high values indicate bottlenecks in the pipeline. Compare with `core_source_lag_seconds` to determine if the delay is in source read or target apply.

  ## Replication pipeline metrics

  <img src="https://mintcdn.com/cockroachlabs/bALSwIJ7kkDMfVP4/images/molt/replicator-metrics-pg.png?fit=max&auto=format&n=bALSwIJ7kkDMfVP4&q=85&s=ff125e4e47c23c27d67818d7414122e8" alt="Single Region MAZ" style={{ border: "0px solid #eee", maxWidth: "80%", display: "block", marginLeft: "auto", marginRight: "auto" }} width="1297" height="228" data-path="images/molt/replicator-metrics-pg.png" />

  ### Source read

  [Source read](#replication-pipeline) metrics track the health of connections to source databases and the volume of incoming changes.

  * <a id="pglogical-dial-success-total" />`pglogical_dial_success_total`
    * Description: Number of times Replicator successfully started logical replication (executed `START_REPLICATION` command).
    * Interpretation: Multiple successes may indicate reconnects. Monitor for connection stability.
  * <a id="pglogical-dial-failure-total" />`pglogical_dial_failure_total`
    * Description: Number of times Replicator failed to start logical replication (failure to execute `START_REPLICATION` command).
    * Interpretation: Nonzero values indicate connection issues. Check network connectivity and source database health.
  * <a id="postgres-mutation-total" />`mutation_total`
    * Description: Total number of mutations processed, labeled by source and mutation type (insert/update/delete).
    * Interpretation: Use to monitor replication throughput and identify traffic patterns.
  * <a id="pglogical-filtered-deletions-total" />`pglogical_filtered_deletions_total`
    * Description: Number of `DELETE` mutations filtered out before buffering when using the <InternalLink path="replicator-flags#ignore-deletions-for-table">`--ignoreDeletionsForTable`</InternalLink> flag.
    * Interpretation: Use to verify that deletions are being filtered as expected for tables specified with `--ignoreDeletionsForTable`.

  ### Core sequencer

  [Core sequencer](#replication-pipeline) metrics track mutation processing, ordering, and transaction coordination.

  * <a id="core-sweep-duration-seconds" />`core_sweep_duration_seconds`
    * Description: Duration of each schema sweep operation, which looks for and applies staged mutations.
    * Interpretation: Long durations indicate that large backlogs, slow staging reads, or slow target writes are affecting throughput.
  * <a id="core-sweep-mutations-applied-total" />`core_sweep_mutations_applied_total`
    * Description: Total count of mutations read from staging and successfully applied to the target database during a sweep.
    * Interpretation: Use to monitor processing throughput. A flat line indicates no mutations are being applied.
  * <a id="core-sweep-success-timestamp-seconds" />`core_sweep_success_timestamp_seconds`
    * Description: Wall time (Unix timestamp) at which a sweep attempt last succeeded.
    * Interpretation: If this value stops updating and becomes stale, it indicates that the sweep has stopped.
  * <a id="core-parallelism-utilization-percent" />`core_parallelism_utilization_percent`
    * Description: Percentage of the configured parallelism that is actively being used for concurrent transaction processing.
    * Interpretation: High utilization indicates bottlenecks in mutation processing.

  ### Target apply

  [Target apply](#replication-pipeline) metrics track mutation application to the target database.

  * <a id="target-apply-queue-size" />`target_apply_queue_size`
    * Description: Number of transactions waiting in the target apply queue.
    * Interpretation: High values indicate target apply cannot keep up with incoming transactions.
  * <a id="apply-duration-seconds" />`apply_duration_seconds`
    * Description: Amount of time taken to successfully apply mutations to a table.
    * Interpretation: High values indicate target database performance issues or contention.
  * <a id="apply-upserts-total" />`apply_upserts_total`
    * Description: Number of rows upserted to the target.
    * Interpretation: Use to monitor write throughput. Should grow steadily during active replication.
  * <a id="apply-deletes-total" />`apply_deletes_total`
    * Description: Number of rows deleted from the target.
    * Interpretation: Use to monitor delete throughput. Compare with delete operations on the source database.
  * <a id="apply-errors-total" />`apply_errors_total`
    * Description: Number of times an error was encountered while applying mutations.
    * Interpretation: Growing error count indicates target database issues or constraint violations.
  * <a id="apply-conflicts-total" />`apply_conflicts_total`
    * Description: Number of rows that experienced a compare-and-set (CAS) conflict.
    * Interpretation: High counts indicate concurrent modifications or stale data conflicts. May require conflict resolution tuning.
  * <a id="apply-resolves-total" />`apply_resolves_total`
    * Description: Number of rows that experienced a compare-and-set (CAS) conflict and were successfully resolved.
    * Interpretation: Compare with `apply_conflicts_total` to verify conflict resolution is working. Should be close to or equal to conflicts.

  ## Userscript metrics

  <InternalLink path="userscript-overview">Userscripts</InternalLink> allow you to define how rows are transformed, filtered, and routed before Replicator writes them to the target database. Replicator exposes Prometheus <InternalLink path="userscript-metrics">metrics</InternalLink> that provide insight into userscript activity, performance, and stability.

  <a id="script-invocations-total" />

  * `script_invocations_total` (counter)
    * Description: Number of times <InternalLink path="userscript-overview">userscript</InternalLink> handler functions (such as `onRowUpsert`, `onRowDelete`, and `onWrite`) are invoked.
    * Interpretation: Use to confirm that userscripts are actively being called, and detect misconfigurations where scripts filter out all data or never run.

  <a id="script-rows-filtered-total" />

  * `script_rows_filtered_total` (counter)
    * Description: Number of rows filtered out by the <InternalLink path="userscript-overview">userscript</InternalLink> (for example, handlers that returned `null` or produced no output).
    * Interpretation: Use to identify scripts that unintentionally drop incoming data, and confirm that logic for filtering out data rows is working as intended.

  <a id="script-rows-processed-total" />

  * `script_rows_processed_total` (counter)
    * Description: Number of rows successfully processed and passed through the <InternalLink path="userscript-overview">userscript</InternalLink>.
    * Interpretation: Use to measure how many rows are being transformed or routed successfully. Compare with [`script_rows_filtered_total`](#script-rows-filtered-total) to understand filtering ratios and validate script logic.

  <a id="script-exec-time-seconds" />

  * `script_exec_time_seconds` (histogram)
    * Description: Measures the execution time of each <InternalLink path="userscript-overview">userscript</InternalLink> function call.
    * Interpretation: Use to detect slow or inefficient userscripts that could introduce replication lag, and identify performance bottlenecks caused by complex transformations or external lookups.

  <a id="script-entry-wait-seconds" />

  * `script_entry_wait_seconds` (histogram)
    * Description: Measures the latency between a row entering the Replicator <InternalLink path="userscript-overview">userscript</InternalLink> queue and the start of its execution inside the JavaScript runtime.
    * Interpretation: Use to detect whether userscripts are queuing up before execution (higher values indicate longer wait times), and monitor how busy the userscript runtime pool is under load.

  <a id="script-errors-total" />

  * `script_errors_total` (counter)
    * Description: Number of errors that occurred during <InternalLink path="userscript-overview">userscript</InternalLink> execution (for example, JavaScript exceptions or runtime errors).
    * Interpretation: Use to surface failing scripts or invalid assumptions about incoming data, and monitor script stability over time and catch regressions early.

  <InternalLink path="userscript-metrics">Read more about userscript metrics</InternalLink>.

  ## Metrics snapshots

  When enabled, the metrics snapshotter periodically writes out a point-in-time snapshot of Replicator's Prometheus metrics to a file in the <InternalLink path="replicator-flags#data-dir">Replicator data directory</InternalLink>. Metrics snapshots can help with debugging when direct access to the Prometheus server is not available, and you can [bundle snapshots and send them to CockroachDB support](#bundle-and-send-metrics-snapshots) to help resolve an issue. A metrics snapshot includes all of the metrics on this page.

  Metrics snapshotting is disabled by default, and can be enabled with the <InternalLink path="replicator-flags#metrics-snapshot-period">`--metricsSnapshotPeriod`</InternalLink> Replicator flag. [Replicator metrics must be enabled](#set-up-metrics) (with the <InternalLink path="replicator-flags#metrics-addr">`--metricsAddr`</InternalLink> flag) in order for metrics snapshotting to work.

  If snapshotting is enabled, the snapshot period must be at least 15 seconds. The recommended range for the snapshot period is 15-60 seconds. The retention policy for metrics snapshot files can be determined by <InternalLink path="replicator-flags#metrics-snapshot-retention-time">time</InternalLink> and by the <InternalLink path="replicator-flags#metrics-snapshot-retention-size">total size</InternalLink> of the snapshot data subdirectory. At least one retention policy must be configured. Snapshots can also be <InternalLink path="replicator-flags#metrics-snapshot-compression">compressed to a gzip file</InternalLink>.

  Changing the snapshotter's configuration requires restarting the Replicator binary with different flags.

  ### Enable metrics snapshotting

  #### Step 1. Run Replicator with the snapshot flags

  The following is an example of a `replicator` command where snapshotting is configured:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  replicator pglogical \
  --targetConn postgres://postgres:postgres@localhost:5432/molt?sslmode=disable \
  --stagingConn postgres://root@localhost:26257/_replicator?sslmode=disable \
  --slotName molt_slot \
  --bindAddr 0.0.0.0:30004 \
  --stagingSchema _replicator \
  --stagingCreateSchema \
  --disableAuthentication \
  --tlsSelfSigned \
  --stageMode crdb \
  --bestEffortWindow 1s \
  --flushSize 1000 \
  --metricsAddr :30005 \
  --metricsSnapshotPeriod 15s \
  --metricsSnapshotCompression gzip \
  --metricsSnapshotRetentionTime 168h \
  -v
  ```
</View>

<View title="MySQL">
  <Tip>
    The instructions in this section are specific to **MySQL** source databases. To see instructions for other source database types, select a different option from the dropdown at the top right of this page.
  </Tip>

  * **Staging**: Buffers mutations for ordered processing and crash recovery.

  * [**Core sequencer**](#core-sequencer): Processes staged mutations, maintains ordering guarantees, and coordinates transaction application.

  * [**Target apply**](#target-apply): Applies mutations to the target database.

  ## Set up metrics

  Enable Replicator metrics by specifying the <InternalLink path="replicator-flags">`--metricsAddr`</InternalLink> flag with a port (or `host:port`) when you start Replicator. This exposes Replicator metrics at `http://{host}:{port}/_/varz`. For example, the following command exposes metrics on port `30005`:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  replicator start \
  --targetConn $TARGET \
  --stagingConn $STAGING \
  --metricsAddr :30005
  ...
  ```

  To collect Replicator metrics, set up [Prometheus](https://prometheus.io/) to scrape the [Replicator metrics endpoint](#metrics-endpoints). To [visualize Replicator metrics](#visualize-metrics), use [Grafana](https://grafana.com/) to create dashboards.

  ## Metrics endpoints

  The following endpoints are available when you [enable Replicator metrics](#set-up-metrics):

  | Endpoint        | Description                               |
  | --------------- | ----------------------------------------- |
  | `/_/varz`       | Prometheus metrics endpoint.              |
  | `/_/diag`       | Structured diagnostic information (JSON). |
  | `/_/healthz`    | Health check endpoint.                    |
  | `/debug/pprof/` | Go pprof handlers for profiling.          |

  For example, to view the current snapshot of Replicator metrics on port `30005`, open `http://localhost:30005/_/varz` in a browser. To track metrics over time and create visualizations, use Prometheus and Grafana as described in [Set up metrics](#set-up-metrics).

  To check Replicator health:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  curl http://localhost:30005/_/healthz
  ```

  ```
  OK
  ```

  ### Visualize metrics

  Use the Replicator Grafana dashboard <InternalLink path="molt-replicator-installation">bundled with your binary</InternalLink> (`replicator_grafana_dashboard.json`) to visualize metrics. The bundled dashboard matches your binary version. Alternatively, you can download the [latest dashboard](https://replicator.cockroachdb.com/replicator_grafana_dashboard.json).

  ## Overall replication metrics

  ### High-level performance metrics

  Monitor the following metrics to track the overall health of the [replication pipeline](#replication-pipeline):

  * <a id="core-source-lag-seconds" />`core_source_lag_seconds`
    * Description: Age of the most recently received checkpoint. This represents the time from source commit to `COMMIT` event processing.
    * Interpretation: If consistently increasing, Replicator is falling behind in reading source changes, and cannot keep pace with database changes.
  * <a id="target-apply-mutation-age-seconds" />`target_apply_mutation_age_seconds`
    * Description: End-to-end replication lag per mutation from source commit to target apply. Measures the difference between current wall time and the mutation's <InternalLink version="stable" path="architecture/storage-layer#mvcc">MVCC timestamp</InternalLink>.
    * Interpretation: Higher values mean that older mutations are being applied, and indicate end-to-end pipeline delays. Compare across tables to find bottlenecks.
  * <a id="target-apply-queue-utilization-percent" />`target_apply_queue_utilization_percent`
    * Description: Percentage of target apply queue capacity utilization.
    * Interpretation: Values above 90 percent indicate severe backpressure throughout the pipeline, and potential data processing delays. Investigate target database performance.

  ### Replication lag

  Monitor the following metrics to track end-to-end replication lag:

  * <a id="source-commit-to-apply-lag-seconds" />`source_commit_to_apply_lag_seconds`
    * Description: Time delta between writing a mutation to the source and writing it to the target.
    * Interpretation: This may indicate the duration of a <InternalLink path="migration-considerations-replication#permissible-downtime">minimum downtime window</InternalLink> due to drainage. Low values (seconds or hundreds of milliseconds) would allow for minimal downtime on cutover.

  * <a id="target-apply-transaction-lag-seconds" />`target_apply_transaction_lag_seconds`
    * Description: Age of the transaction applied to the target table, measuring time from source commit to target apply.
    * Interpretation: Consistently high values indicate bottlenecks in the pipeline. Compare with `core_source_lag_seconds` to determine if the delay is in source read or target apply.

  ## Replication pipeline metrics

  <img src="https://mintcdn.com/cockroachlabs/bALSwIJ7kkDMfVP4/images/molt/replicator-metrics-mysql.png?fit=max&auto=format&n=bALSwIJ7kkDMfVP4&q=85&s=3c4a171cff4f1cdf8544ee669599dd43" alt="Single Region MAZ" style={{ border: "0px solid #eee", maxWidth: "80%", display: "block", marginLeft: "auto", marginRight: "auto" }} width="1296" height="228" data-path="images/molt/replicator-metrics-mysql.png" />

  ### Source read

  [Source read](#replication-pipeline) metrics track the health of connections to source databases and the volume of incoming changes.

  * <a id="mylogical-dial-success-total" />`mylogical_dial_success_total`
    * Description: Number of times Replicator successfully started logical replication.
    * Interpretation: Multiple successes may indicate reconnects. Monitor for connection stability.
  * <a id="mylogical-dial-failure-total" />`mylogical_dial_failure_total`
    * Description: Number of times Replicator failed to start logical replication.
    * Interpretation: Nonzero values indicate connection issues. Check network connectivity and source database health.
  * <a id="mysql-mutation-total" />`mutation_total`
    * Description: Total number of mutations processed, labeled by source and mutation type (insert/update/delete).
    * Interpretation: Use to monitor replication throughput and identify traffic patterns.

  ### Core sequencer

  [Core sequencer](#replication-pipeline) metrics track mutation processing, ordering, and transaction coordination.

  * <a id="core-sweep-duration-seconds" />`core_sweep_duration_seconds`
    * Description: Duration of each schema sweep operation, which looks for and applies staged mutations.
    * Interpretation: Long durations indicate that large backlogs, slow staging reads, or slow target writes are affecting throughput.
  * <a id="core-sweep-mutations-applied-total" />`core_sweep_mutations_applied_total`
    * Description: Total count of mutations read from staging and successfully applied to the target database during a sweep.
    * Interpretation: Use to monitor processing throughput. A flat line indicates no mutations are being applied.
  * <a id="core-sweep-success-timestamp-seconds" />`core_sweep_success_timestamp_seconds`
    * Description: Wall time (Unix timestamp) at which a sweep attempt last succeeded.
    * Interpretation: If this value stops updating and becomes stale, it indicates that the sweep has stopped.
  * <a id="core-parallelism-utilization-percent" />`core_parallelism_utilization_percent`
    * Description: Percentage of the configured parallelism that is actively being used for concurrent transaction processing.
    * Interpretation: High utilization indicates bottlenecks in mutation processing.

  ### Target apply

  [Target apply](#replication-pipeline) metrics track mutation application to the target database.

  * <a id="target-apply-queue-size" />`target_apply_queue_size`
    * Description: Number of transactions waiting in the target apply queue.
    * Interpretation: High values indicate target apply cannot keep up with incoming transactions.
  * <a id="apply-duration-seconds" />`apply_duration_seconds`
    * Description: Amount of time taken to successfully apply mutations to a table.
    * Interpretation: High values indicate target database performance issues or contention.
  * <a id="apply-upserts-total" />`apply_upserts_total`
    * Description: Number of rows upserted to the target.
    * Interpretation: Use to monitor write throughput. Should grow steadily during active replication.
  * <a id="apply-deletes-total" />`apply_deletes_total`
    * Description: Number of rows deleted from the target.
    * Interpretation: Use to monitor delete throughput. Compare with delete operations on the source database.
  * <a id="apply-errors-total" />`apply_errors_total`
    * Description: Number of times an error was encountered while applying mutations.
    * Interpretation: Growing error count indicates target database issues or constraint violations.
  * <a id="apply-conflicts-total" />`apply_conflicts_total`
    * Description: Number of rows that experienced a compare-and-set (CAS) conflict.
    * Interpretation: High counts indicate concurrent modifications or stale data conflicts. May require conflict resolution tuning.
  * <a id="apply-resolves-total" />`apply_resolves_total`
    * Description: Number of rows that experienced a compare-and-set (CAS) conflict and were successfully resolved.
    * Interpretation: Compare with `apply_conflicts_total` to verify conflict resolution is working. Should be close to or equal to conflicts.

  ## Userscript metrics

  <InternalLink path="userscript-overview">Userscripts</InternalLink> allow you to define how rows are transformed, filtered, and routed before Replicator writes them to the target database. Replicator exposes Prometheus <InternalLink path="userscript-metrics">metrics</InternalLink> that provide insight into userscript activity, performance, and stability.

  <a id="script-invocations-total" />

  * `script_invocations_total` (counter)
    * Description: Number of times <InternalLink path="userscript-overview">userscript</InternalLink> handler functions (such as `onRowUpsert`, `onRowDelete`, and `onWrite`) are invoked.
    * Interpretation: Use to confirm that userscripts are actively being called, and detect misconfigurations where scripts filter out all data or never run.

  <a id="script-rows-filtered-total" />

  * `script_rows_filtered_total` (counter)
    * Description: Number of rows filtered out by the <InternalLink path="userscript-overview">userscript</InternalLink> (for example, handlers that returned `null` or produced no output).
    * Interpretation: Use to identify scripts that unintentionally drop incoming data, and confirm that logic for filtering out data rows is working as intended.

  <a id="script-rows-processed-total" />

  * `script_rows_processed_total` (counter)
    * Description: Number of rows successfully processed and passed through the <InternalLink path="userscript-overview">userscript</InternalLink>.
    * Interpretation: Use to measure how many rows are being transformed or routed successfully. Compare with [`script_rows_filtered_total`](#script-rows-filtered-total) to understand filtering ratios and validate script logic.

  <a id="script-exec-time-seconds" />

  * `script_exec_time_seconds` (histogram)
    * Description: Measures the execution time of each <InternalLink path="userscript-overview">userscript</InternalLink> function call.
    * Interpretation: Use to detect slow or inefficient userscripts that could introduce replication lag, and identify performance bottlenecks caused by complex transformations or external lookups.

  <a id="script-entry-wait-seconds" />

  * `script_entry_wait_seconds` (histogram)
    * Description: Measures the latency between a row entering the Replicator <InternalLink path="userscript-overview">userscript</InternalLink> queue and the start of its execution inside the JavaScript runtime.
    * Interpretation: Use to detect whether userscripts are queuing up before execution (higher values indicate longer wait times), and monitor how busy the userscript runtime pool is under load.

  <a id="script-errors-total" />

  * `script_errors_total` (counter)
    * Description: Number of errors that occurred during <InternalLink path="userscript-overview">userscript</InternalLink> execution (for example, JavaScript exceptions or runtime errors).
    * Interpretation: Use to surface failing scripts or invalid assumptions about incoming data, and monitor script stability over time and catch regressions early.

  <InternalLink path="userscript-metrics">Read more about userscript metrics</InternalLink>.

  ## Metrics snapshots

  When enabled, the metrics snapshotter periodically writes out a point-in-time snapshot of Replicator's Prometheus metrics to a file in the <InternalLink path="replicator-flags#data-dir">Replicator data directory</InternalLink>. Metrics snapshots can help with debugging when direct access to the Prometheus server is not available, and you can [bundle snapshots and send them to CockroachDB support](#bundle-and-send-metrics-snapshots) to help resolve an issue. A metrics snapshot includes all of the metrics on this page.

  Metrics snapshotting is disabled by default, and can be enabled with the <InternalLink path="replicator-flags#metrics-snapshot-period">`--metricsSnapshotPeriod`</InternalLink> Replicator flag. [Replicator metrics must be enabled](#set-up-metrics) (with the <InternalLink path="replicator-flags#metrics-addr">`--metricsAddr`</InternalLink> flag) in order for metrics snapshotting to work.

  If snapshotting is enabled, the snapshot period must be at least 15 seconds. The recommended range for the snapshot period is 15-60 seconds. The retention policy for metrics snapshot files can be determined by <InternalLink path="replicator-flags#metrics-snapshot-retention-time">time</InternalLink> and by the <InternalLink path="replicator-flags#metrics-snapshot-retention-size">total size</InternalLink> of the snapshot data subdirectory. At least one retention policy must be configured. Snapshots can also be <InternalLink path="replicator-flags#metrics-snapshot-compression">compressed to a gzip file</InternalLink>.

  Changing the snapshotter's configuration requires restarting the Replicator binary with different flags.

  ### Enable metrics snapshotting

  #### Step 1. Run Replicator with the snapshot flags

  The following is an example of a `replicator` command where snapshotting is configured:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  replicator mylogical \
  --targetConn postgres://postgres:postgres@localhost:5432/molt?sslmode=disable \
  --stagingConn postgres://root@localhost:26257/_replicator?sslmode=disable \
  --defaultGTIDSet '4c658ae6-e8ad-11ef-8449-0242ac140006:1-29' \
  --bindAddr 0.0.0.0:30004 \
  --stagingSchema _replicator \
  --stagingCreateSchema \
  --disableAuthentication \
  --tlsSelfSigned \
  --stageMode crdb \
  --bestEffortWindow 1s \
  --flushSize 1000 \
  --metricsAddr :30005 \
  --metricsSnapshotPeriod 15s \
  --metricsSnapshotCompression gzip \
  --metricsSnapshotRetentionTime 168h \
  -v
  ```
</View>

<View title="Oracle">
  <Tip>
    The instructions in this section are specific to **Oracle** source databases. To see instructions for other source database types, select a different option from the dropdown at the top right of this page.
  </Tip>

  * **Staging**: Buffers mutations for ordered processing and crash recovery.

  * [**Core sequencer**](#core-sequencer): Processes staged mutations, maintains ordering guarantees, and coordinates transaction application.

  * [**Target apply**](#target-apply): Applies mutations to the target database.

  ## Set up metrics

  Enable Replicator metrics by specifying the <InternalLink path="replicator-flags">`--metricsAddr`</InternalLink> flag with a port (or `host:port`) when you start Replicator. This exposes Replicator metrics at `http://{host}:{port}/_/varz`. For example, the following command exposes metrics on port `30005`:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  replicator start \
  --targetConn $TARGET \
  --stagingConn $STAGING \
  --metricsAddr :30005
  ...
  ```

  To collect Replicator metrics, set up [Prometheus](https://prometheus.io/) to scrape the [Replicator metrics endpoint](#metrics-endpoints). To [visualize Replicator metrics](#visualize-metrics), use [Grafana](https://grafana.com/) to create dashboards.

  ## Metrics endpoints

  The following endpoints are available when you [enable Replicator metrics](#set-up-metrics):

  | Endpoint        | Description                               |
  | --------------- | ----------------------------------------- |
  | `/_/varz`       | Prometheus metrics endpoint.              |
  | `/_/diag`       | Structured diagnostic information (JSON). |
  | `/_/healthz`    | Health check endpoint.                    |
  | `/debug/pprof/` | Go pprof handlers for profiling.          |

  For example, to view the current snapshot of Replicator metrics on port `30005`, open `http://localhost:30005/_/varz` in a browser. To track metrics over time and create visualizations, use Prometheus and Grafana as described in [Set up metrics](#set-up-metrics).

  To check Replicator health:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  curl http://localhost:30005/_/healthz
  ```

  ```
  OK
  ```

  ### Visualize metrics

  Use the Replicator Grafana dashboards <InternalLink path="molt-replicator-installation">bundled with your binary</InternalLink> to visualize metrics. The general Replicator dashboard (`replicator_grafana_dashboard.json`) displays overall replication metrics, and the Oracle-specific dashboard (`replicator_oracle_grafana_dashboard.json`) displays [Oracle source metrics](#source-read). The bundled dashboards match your binary version. Alternatively, you can download the latest dashboards for [Replicator](https://replicator.cockroachdb.com/replicator_grafana_dashboard.json) and [Oracle source metrics](https://replicator.cockroachdb.com/replicator_oracle_grafana_dashboard.json).

  ## Overall replication metrics

  ### High-level performance metrics

  Monitor the following metrics to track the overall health of the [replication pipeline](#replication-pipeline):

  * <a id="target-apply-queue-utilization-percent" />`target_apply_queue_utilization_percent`
    * Description: Percentage of target apply queue capacity utilization.
    * Interpretation: Values above 90 percent indicate severe backpressure throughout the pipeline, and potential data processing delays. Increase <InternalLink path="replicator-flags#target-apply-queue-size">`--targetApplyQueueSize`</InternalLink> or investigate target database performance.

  ### Replication lag

  Monitor the following metrics to track end-to-end replication lag:

  * <a id="source-commit-to-apply-lag-seconds" />`source_commit_to_apply_lag_seconds`
    * Description: Time delta between writing a mutation to the source and writing it to the target.
    * Interpretation: This may indicate the duration of a <InternalLink path="migration-considerations-replication#permissible-downtime">minimum downtime window</InternalLink> due to drainage. Low values (seconds or hundreds of milliseconds) would allow for minimal downtime on cutover.

  ## Replication pipeline metrics

  <img src="https://mintcdn.com/cockroachlabs/bALSwIJ7kkDMfVP4/images/molt/replicator-metrics-oracle.png?fit=max&auto=format&n=bALSwIJ7kkDMfVP4&q=85&s=455c9ca9182f36399f24238fd8a071aa" alt="Single Region MAZ" style={{ border: "0px solid #eee", maxWidth: "80%", display: "block", marginLeft: "auto", marginRight: "auto" }} width="1444" height="250" data-path="images/molt/replicator-metrics-oracle.png" />

  ### Source read

  [Source read](#replication-pipeline) metrics track the health of connections to source databases and the volume of incoming changes.

  <Tip>
    To visualize the following metrics, import the Oracle Grafana dashboard <InternalLink path="molt-replicator-installation">bundled with your binary</InternalLink> (`replicator_oracle_grafana_dashboard.json`). The bundled dashboard matches your binary version. Alternatively, you can download the [latest dashboard](https://replicator.cockroachdb.com/replicator_oracle_grafana_dashboard.json).
  </Tip>

  * <a id="oraclelogminer-scn-interval-size" />`oraclelogminer_scn_interval_size`
    * Description: Size of the interval from the start SCN to the current Oracle SCN.
    * Interpretation: Values larger than the <InternalLink path="replicator-flags#scn-window-size">`--scnWindowSize`</InternalLink> flag value indicate replication lag, or that replication is idle.
  * <a id="oraclelogminer-time-per-window-seconds" />`oraclelogminer_time_per_window_seconds`
    * Description: Amount of time taken to fully process an SCN interval.
    * Interpretation: Large values indicate Oracle slowdown, blocked replication loop, or slow processing.
  * <a id="oraclelogminer-query-redo-logs-duration-seconds" />`oraclelogminer_query_redo_logs_duration_seconds`
    * Description: Amount of time taken to query redo logs from LogMiner.
    * Interpretation: High values indicate Oracle is under load or the SCN interval is too large.
  * <a id="oraclelogminer-num-inflight-transactions-in-memory" />`oraclelogminer_num_inflight_transactions_in_memory`
    * Description: Current number of in-flight transactions in memory.
    * Interpretation: High counts indicate long-running transactions on source. Monitor for memory usage.
  * <a id="oraclelogminer-num-async-checkpoints-in-queue" />`oraclelogminer_num_async_checkpoints_in_queue`
    * Description: Checkpoints queued for processing against staging database.
    * Interpretation: Values close to the `--checkpointQueueBufferSize` flag value indicate checkpoint processing cannot keep up with incoming checkpoints.
  * <a id="oraclelogminer-upsert-checkpoints-duration" />`oraclelogminer_upsert_checkpoints_duration`
    * Description: Amount of time taken to upsert checkpoint batch into staging database.
    * Interpretation: High values indicate the staging database is under heavy load or batch size is too large.
  * <a id="oraclelogminer-delete-checkpoints-duration" />`oraclelogminer_delete_checkpoints_duration`
    * Description: Amount of time taken to delete old checkpoints from the staging database.
    * Interpretation: High values indicate staging database load or long-running transactions preventing checkpoint deletion.
  * <a id="oracle-mutation-total" />`mutation_total`
    * Description: Total number of mutations processed, labeled by source and mutation type (insert/update/delete).
    * Interpretation: Use to monitor replication throughput and identify traffic patterns.

  ### Core sequencer

  [Core sequencer](#replication-pipeline) metrics track mutation processing, ordering, and transaction coordination.

  * <a id="core-sweep-duration-seconds" />`core_sweep_duration_seconds`
    * Description: Duration of each schema sweep operation, which looks for and applies staged mutations.
    * Interpretation: Long durations indicate that large backlogs, slow staging reads, or slow target writes are affecting throughput.
  * <a id="core-sweep-mutations-applied-total" />`core_sweep_mutations_applied_total`
    * Description: Total count of mutations read from staging and successfully applied to the target database during a sweep.
    * Interpretation: Use to monitor processing throughput. A flat line indicates no mutations are being applied.
  * <a id="core-sweep-success-timestamp-seconds" />`core_sweep_success_timestamp_seconds`
    * Description: Wall time (Unix timestamp) at which a sweep attempt last succeeded.
    * Interpretation: If this value stops updating and becomes stale, it indicates that the sweep has stopped.
  * <a id="core-parallelism-utilization-percent" />`core_parallelism_utilization_percent`
    * Description: Percentage of the configured parallelism that is actively being used for concurrent transaction processing.
    * Interpretation: High utilization indicates bottlenecks in mutation processing.

  ### Target apply

  [Target apply](#replication-pipeline) metrics track mutation application to the target database.

  * <a id="target-apply-queue-size" />`target_apply_queue_size`
    * Description: Number of transactions waiting in the target apply queue.
    * Interpretation: High values indicate target apply cannot keep up with incoming transactions.
  * <a id="apply-duration-seconds" />`apply_duration_seconds`
    * Description: Amount of time taken to successfully apply mutations to a table.
    * Interpretation: High values indicate target database performance issues or contention.
  * <a id="apply-upserts-total" />`apply_upserts_total`
    * Description: Number of rows upserted to the target.
    * Interpretation: Use to monitor write throughput. Should grow steadily during active replication.
  * <a id="apply-deletes-total" />`apply_deletes_total`
    * Description: Number of rows deleted from the target.
    * Interpretation: Use to monitor delete throughput. Compare with delete operations on the source database.
  * <a id="apply-errors-total" />`apply_errors_total`
    * Description: Number of times an error was encountered while applying mutations.
    * Interpretation: Growing error count indicates target database issues or constraint violations.
  * <a id="apply-conflicts-total" />`apply_conflicts_total`
    * Description: Number of rows that experienced a compare-and-set (CAS) conflict.
    * Interpretation: High counts indicate concurrent modifications or stale data conflicts. May require conflict resolution tuning.
  * <a id="apply-resolves-total" />`apply_resolves_total`
    * Description: Number of rows that experienced a compare-and-set (CAS) conflict and were successfully resolved.
    * Interpretation: Compare with `apply_conflicts_total` to verify conflict resolution is working. Should be close to or equal to conflicts.

  ## Userscript metrics

  <InternalLink path="userscript-overview">Userscripts</InternalLink> allow you to define how rows are transformed, filtered, and routed before Replicator writes them to the target database. Replicator exposes Prometheus <InternalLink path="userscript-metrics">metrics</InternalLink> that provide insight into userscript activity, performance, and stability.

  <a id="script-invocations-total" />

  * `script_invocations_total` (counter)
    * Description: Number of times <InternalLink path="userscript-overview">userscript</InternalLink> handler functions (such as `onRowUpsert`, `onRowDelete`, and `onWrite`) are invoked.
    * Interpretation: Use to confirm that userscripts are actively being called, and detect misconfigurations where scripts filter out all data or never run.

  <a id="script-rows-filtered-total" />

  * `script_rows_filtered_total` (counter)
    * Description: Number of rows filtered out by the <InternalLink path="userscript-overview">userscript</InternalLink> (for example, handlers that returned `null` or produced no output).
    * Interpretation: Use to identify scripts that unintentionally drop incoming data, and confirm that logic for filtering out data rows is working as intended.

  <a id="script-rows-processed-total" />

  * `script_rows_processed_total` (counter)
    * Description: Number of rows successfully processed and passed through the <InternalLink path="userscript-overview">userscript</InternalLink>.
    * Interpretation: Use to measure how many rows are being transformed or routed successfully. Compare with [`script_rows_filtered_total`](#script-rows-filtered-total) to understand filtering ratios and validate script logic.

  <a id="script-exec-time-seconds" />

  * `script_exec_time_seconds` (histogram)
    * Description: Measures the execution time of each <InternalLink path="userscript-overview">userscript</InternalLink> function call.
    * Interpretation: Use to detect slow or inefficient userscripts that could introduce replication lag, and identify performance bottlenecks caused by complex transformations or external lookups.

  <a id="script-entry-wait-seconds" />

  * `script_entry_wait_seconds` (histogram)
    * Description: Measures the latency between a row entering the Replicator <InternalLink path="userscript-overview">userscript</InternalLink> queue and the start of its execution inside the JavaScript runtime.
    * Interpretation: Use to detect whether userscripts are queuing up before execution (higher values indicate longer wait times), and monitor how busy the userscript runtime pool is under load.

  <a id="script-errors-total" />

  * `script_errors_total` (counter)
    * Description: Number of errors that occurred during <InternalLink path="userscript-overview">userscript</InternalLink> execution (for example, JavaScript exceptions or runtime errors).
    * Interpretation: Use to surface failing scripts or invalid assumptions about incoming data, and monitor script stability over time and catch regressions early.

  <InternalLink path="userscript-metrics">Read more about userscript metrics</InternalLink>.

  ## Metrics snapshots

  When enabled, the metrics snapshotter periodically writes out a point-in-time snapshot of Replicator's Prometheus metrics to a file in the <InternalLink path="replicator-flags#data-dir">Replicator data directory</InternalLink>. Metrics snapshots can help with debugging when direct access to the Prometheus server is not available, and you can [bundle snapshots and send them to CockroachDB support](#bundle-and-send-metrics-snapshots) to help resolve an issue. A metrics snapshot includes all of the metrics on this page.

  Metrics snapshotting is disabled by default, and can be enabled with the <InternalLink path="replicator-flags#metrics-snapshot-period">`--metricsSnapshotPeriod`</InternalLink> Replicator flag. [Replicator metrics must be enabled](#set-up-metrics) (with the <InternalLink path="replicator-flags#metrics-addr">`--metricsAddr`</InternalLink> flag) in order for metrics snapshotting to work.

  If snapshotting is enabled, the snapshot period must be at least 15 seconds. The recommended range for the snapshot period is 15-60 seconds. The retention policy for metrics snapshot files can be determined by <InternalLink path="replicator-flags#metrics-snapshot-retention-time">time</InternalLink> and by the <InternalLink path="replicator-flags#metrics-snapshot-retention-size">total size</InternalLink> of the snapshot data subdirectory. At least one retention policy must be configured. Snapshots can also be <InternalLink path="replicator-flags#metrics-snapshot-compression">compressed to a gzip file</InternalLink>.

  Changing the snapshotter's configuration requires restarting the Replicator binary with different flags.

  ### Enable metrics snapshotting

  #### Step 1. Run Replicator with the snapshot flags

  The following is an example of a `replicator` command where snapshotting is configured:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  replicator oraclelogminer \
  --targetConn postgres://postgres:postgres@localhost:5432/molt?sslmode=disable \
  --stagingConn postgres://root@localhost:26257/_replicator?sslmode=disable \
  --scn 26685786 \
  --backfillFromSCN 26685444 \
  --bindAddr 0.0.0.0:30004 \
  --stagingSchema _replicator \
  --stagingCreateSchema \
  --disableAuthentication \
  --tlsSelfSigned \
  --stageMode crdb \
  --bestEffortWindow 1s \
  --flushSize 1000 \
  --metricsAddr :30005 \
  --metricsSnapshotPeriod 15s \
  --metricsSnapshotCompression gzip \
  --metricsSnapshotRetentionTime 168h \
  -v
  ```
</View>

<View title="CockroachDB">
  <Tip>
    The instructions in this section are specific to **CockroachDB** source databases. To see instructions for other source database types, select a different option from the dropdown at the top right of this page.
  </Tip>

  * [**Staging**](#staging): Buffers mutations for ordered processing and crash recovery.

  * [**Core sequencer**](#core-sequencer): Processes staged mutations, maintains ordering guarantees, and coordinates transaction application.

  * [**Target apply**](#target-apply): Applies mutations to the target database.

  ## Set up metrics

  Enable Replicator metrics by specifying the <InternalLink path="replicator-flags">`--metricsAddr`</InternalLink> flag with a port (or `host:port`) when you start Replicator. This exposes Replicator metrics at `http://{host}:{port}/_/varz`. For example, the following command exposes metrics on port `30005`:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  replicator start \
  --targetConn $TARGET \
  --stagingConn $STAGING \
  --metricsAddr :30005
  ...
  ```

  To collect Replicator metrics, set up [Prometheus](https://prometheus.io/) to scrape the [Replicator metrics endpoint](#metrics-endpoints). To [visualize Replicator metrics](#visualize-metrics), use [Grafana](https://grafana.com/) to create dashboards.

  ## Metrics endpoints

  The following endpoints are available when you [enable Replicator metrics](#set-up-metrics):

  | Endpoint        | Description                               |
  | --------------- | ----------------------------------------- |
  | `/_/varz`       | Prometheus metrics endpoint.              |
  | `/_/diag`       | Structured diagnostic information (JSON). |
  | `/_/healthz`    | Health check endpoint.                    |
  | `/debug/pprof/` | Go pprof handlers for profiling.          |

  For example, to view the current snapshot of Replicator metrics on port `30005`, open `http://localhost:30005/_/varz` in a browser. To track metrics over time and create visualizations, use Prometheus and Grafana as described in [Set up metrics](#set-up-metrics).

  To check Replicator health:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  curl http://localhost:30005/_/healthz
  ```

  ```
  OK
  ```

  ### Visualize metrics

  Use the Replicator Grafana dashboard <InternalLink path="molt-replicator-installation">bundled with your binary</InternalLink> (`replicator_grafana_dashboard.json`) to visualize metrics. The bundled dashboard matches your binary version. Alternatively, you can download the [latest dashboard](https://replicator.cockroachdb.com/replicator_grafana_dashboard.json).

  ## Overall replication metrics

  ### High-level performance metrics

  Monitor the following metrics to track the overall health of the [replication pipeline](#replication-pipeline):

  * <a id="core-source-lag-seconds" />`core_source_lag_seconds`
    * Description: Age of the most recently received checkpoint. This represents the time elapsed since the latest received resolved timestamp.
    * Interpretation: If consistently increasing, Replicator is falling behind in reading source changes, and cannot keep pace with database changes.
  * <a id="target-apply-mutation-age-seconds" />`target_apply_mutation_age_seconds`
    * Description: End-to-end replication lag per mutation from source commit to target apply. Measures the difference between current wall time and the mutation's <InternalLink version="stable" path="architecture/storage-layer#mvcc">MVCC timestamp</InternalLink>.
    * Interpretation: Higher values mean that older mutations are being applied, and indicate end-to-end pipeline delays. Compare across tables to find bottlenecks.
  * <a id="target-apply-queue-utilization-percent" />`target_apply_queue_utilization_percent`
    * Description: Percentage of target apply queue capacity utilization.
    * Interpretation: Values above 90 percent indicate severe backpressure throughout the pipeline, and potential data processing delays. Investigate target database performance.

  ### Replication lag

  Monitor the following metrics to track end-to-end replication lag:

  * <a id="source-commit-to-apply-lag-seconds" />`source_commit_to_apply_lag_seconds`
    * Description: Time delta between writing a mutation to the source and writing it to the target.
    * Interpretation: This may indicate the duration of a <InternalLink path="migration-considerations-replication#permissible-downtime">minimum downtime window</InternalLink> due to drainage. Low values (seconds or hundreds of milliseconds) would allow for minimal downtime on cutover.

  * <a id="target-apply-transaction-lag-seconds" />`target_apply_transaction_lag_seconds`
    * Description: Age of the transaction applied to the target table, measuring time from source commit to target apply.
    * Interpretation: Consistently high values indicate bottlenecks in the pipeline. Compare with `core_source_lag_seconds` to determine if the delay is in source read or target apply.

  ### Progress tracking

  Monitor the following metrics to track checkpoint progress:

  * <a id="target-applied-timestamp-seconds" />`target_applied_timestamp_seconds`
    * Description: Wall time (Unix timestamp) of the most recently applied resolved timestamp.
    * Interpretation: Use to verify continuous progress. Stale values indicate apply stalls.
  * <a id="target-pending-timestamp-seconds" />`target_pending_timestamp_seconds`
    * Description: Wall time (Unix timestamp) of the most recently received resolved timestamp.
    * Interpretation: A gap between this metric and `target_applied_timestamp_seconds` indicates apply backlog, meaning that the pipeline cannot keep up with incoming changes.

  ## Replication pipeline metrics

  <img src="https://mintcdn.com/cockroachlabs/bALSwIJ7kkDMfVP4/images/molt/replicator-metrics-crdb.png?fit=max&auto=format&n=bALSwIJ7kkDMfVP4&q=85&s=5c88282e10527424fcd247e671935ae4" alt="Single Region MAZ" style={{ border: "0px solid #eee", maxWidth: "80%", display: "block", marginLeft: "auto", marginRight: "auto" }} width="1747" height="228" data-path="images/molt/replicator-metrics-crdb.png" />

  ### Source read

  [Source read](#replication-pipeline) metrics track the health of connections to source databases and the volume of incoming changes.

  * <a id="checkpoint-committed-age-seconds" />`checkpoint_committed_age_seconds`
    * Description: Age of the committed checkpoint.
    * Interpretation: Increasing values indicate checkpoint commits are falling behind, which affects crash recovery capability.
  * <a id="checkpoint-proposed-age-seconds" />`checkpoint_proposed_age_seconds`
    * Description: Age of the proposed checkpoint.
    * Interpretation: A gap with `checkpoint_committed_age_seconds` indicates checkpoint commit lag.
  * <a id="checkpoint-commit-duration-seconds" />`checkpoint_commit_duration_seconds`
    * Description: Amount of time taken to save the committed checkpoint to the staging database.
    * Interpretation: High values indicate staging database bottlenecks due to write contention or performance issues.
  * <a id="checkpoint-proposed-going-backwards-errors-total" />`checkpoint_proposed_going_backwards_errors_total`
    * Description: Number of times an error condition occurred where the changefeed was restarted.
    * Interpretation: Indicates source changefeed restart or time regression. Requires immediate investigation of source changefeed stability.

  ### Staging

  [Staging](#replication-pipeline) metrics track the health of the staging layer where mutations are buffered for ordered processing.

  <Note>
    For checkpoint terminology, refer to the <InternalLink path="molt-replicator#terminology">MOLT Replicator documentation</InternalLink>.
  </Note>

  * <a id="stage-commit-lag-seconds" />`stage_commit_lag_seconds`
    * Description: Time between writing a mutation to source and writing it to staging.
    * Interpretation: High values indicate delays in getting data into the staging layer.
  * <a id="stage-mutations-total" />`stage_mutations_total`
    * Description: Number of mutations staged for each table.
    * Interpretation: Use to monitor staging throughput per table.
  * <a id="stage-duration-seconds" />`stage_duration_seconds`
    * Description: Amount of time taken to successfully stage mutations.
    * Interpretation: High values indicate write performance issues on the staging database.

  ### Core sequencer

  [Core sequencer](#replication-pipeline) metrics track mutation processing, ordering, and transaction coordination.

  * <a id="core-sweep-duration-seconds" />`core_sweep_duration_seconds`
    * Description: Duration of each schema sweep operation, which looks for and applies staged mutations.
    * Interpretation: Long durations indicate that large backlogs, slow staging reads, or slow target writes are affecting throughput.
  * <a id="core-sweep-mutations-applied-total" />`core_sweep_mutations_applied_total`
    * Description: Total count of mutations read from staging and successfully applied to the target database during a sweep.
    * Interpretation: Use to monitor processing throughput. A flat line indicates no mutations are being applied.
  * <a id="core-sweep-success-timestamp-seconds" />`core_sweep_success_timestamp_seconds`
    * Description: Wall time (Unix timestamp) at which a sweep attempt last succeeded.
    * Interpretation: If this value stops updating and becomes stale, it indicates that the sweep has stopped.
  * <a id="core-parallelism-utilization-percent" />`core_parallelism_utilization_percent`
    * Description: Percentage of the configured parallelism that is actively being used for concurrent transaction processing.
    * Interpretation: High utilization indicates bottlenecks in mutation processing.

  ### Target apply

  [Target apply](#replication-pipeline) metrics track mutation application to the target database.

  * <a id="target-apply-queue-size" />`target_apply_queue_size`
    * Description: Number of transactions waiting in the target apply queue.
    * Interpretation: High values indicate target apply cannot keep up with incoming transactions.
  * <a id="apply-duration-seconds" />`apply_duration_seconds`
    * Description: Amount of time taken to successfully apply mutations to a table.
    * Interpretation: High values indicate target database performance issues or contention.
  * <a id="apply-upserts-total" />`apply_upserts_total`
    * Description: Number of rows upserted to the target.
    * Interpretation: Use to monitor write throughput. Should grow steadily during active replication.
  * <a id="apply-deletes-total" />`apply_deletes_total`
    * Description: Number of rows deleted from the target.
    * Interpretation: Use to monitor delete throughput. Compare with delete operations on the source database.
  * <a id="apply-errors-total" />`apply_errors_total`
    * Description: Number of times an error was encountered while applying mutations.
    * Interpretation: Growing error count indicates target database issues or constraint violations.
  * <a id="apply-conflicts-total" />`apply_conflicts_total`
    * Description: Number of rows that experienced a compare-and-set (CAS) conflict.
    * Interpretation: High counts indicate concurrent modifications or stale data conflicts. May require conflict resolution tuning.
  * <a id="apply-resolves-total" />`apply_resolves_total`
    * Description: Number of rows that experienced a compare-and-set (CAS) conflict and were successfully resolved.
    * Interpretation: Compare with `apply_conflicts_total` to verify conflict resolution is working. Should be close to or equal to conflicts.

  ## Userscript metrics

  <InternalLink path="userscript-overview">Userscripts</InternalLink> allow you to define how rows are transformed, filtered, and routed before Replicator writes them to the target database. Replicator exposes Prometheus <InternalLink path="userscript-metrics">metrics</InternalLink> that provide insight into userscript activity, performance, and stability.

  <a id="script-invocations-total" />

  * `script_invocations_total` (counter)
    * Description: Number of times <InternalLink path="userscript-overview">userscript</InternalLink> handler functions (such as `onRowUpsert`, `onRowDelete`, and `onWrite`) are invoked.
    * Interpretation: Use to confirm that userscripts are actively being called, and detect misconfigurations where scripts filter out all data or never run.

  <a id="script-rows-filtered-total" />

  * `script_rows_filtered_total` (counter)
    * Description: Number of rows filtered out by the <InternalLink path="userscript-overview">userscript</InternalLink> (for example, handlers that returned `null` or produced no output).
    * Interpretation: Use to identify scripts that unintentionally drop incoming data, and confirm that logic for filtering out data rows is working as intended.

  <a id="script-rows-processed-total" />

  * `script_rows_processed_total` (counter)
    * Description: Number of rows successfully processed and passed through the <InternalLink path="userscript-overview">userscript</InternalLink>.
    * Interpretation: Use to measure how many rows are being transformed or routed successfully. Compare with [`script_rows_filtered_total`](#script-rows-filtered-total) to understand filtering ratios and validate script logic.

  <a id="script-exec-time-seconds" />

  * `script_exec_time_seconds` (histogram)
    * Description: Measures the execution time of each <InternalLink path="userscript-overview">userscript</InternalLink> function call.
    * Interpretation: Use to detect slow or inefficient userscripts that could introduce replication lag, and identify performance bottlenecks caused by complex transformations or external lookups.

  <a id="script-entry-wait-seconds" />

  * `script_entry_wait_seconds` (histogram)
    * Description: Measures the latency between a row entering the Replicator <InternalLink path="userscript-overview">userscript</InternalLink> queue and the start of its execution inside the JavaScript runtime.
    * Interpretation: Use to detect whether userscripts are queuing up before execution (higher values indicate longer wait times), and monitor how busy the userscript runtime pool is under load.

  <a id="script-errors-total" />

  * `script_errors_total` (counter)
    * Description: Number of errors that occurred during <InternalLink path="userscript-overview">userscript</InternalLink> execution (for example, JavaScript exceptions or runtime errors).
    * Interpretation: Use to surface failing scripts or invalid assumptions about incoming data, and monitor script stability over time and catch regressions early.

  <InternalLink path="userscript-metrics">Read more about userscript metrics</InternalLink>.

  ## Metrics snapshots

  When enabled, the metrics snapshotter periodically writes out a point-in-time snapshot of Replicator's Prometheus metrics to a file in the <InternalLink path="replicator-flags#data-dir">Replicator data directory</InternalLink>. Metrics snapshots can help with debugging when direct access to the Prometheus server is not available, and you can [bundle snapshots and send them to CockroachDB support](#bundle-and-send-metrics-snapshots) to help resolve an issue. A metrics snapshot includes all of the metrics on this page.

  Metrics snapshotting is disabled by default, and can be enabled with the <InternalLink path="replicator-flags">`--metricsSnapshotPeriod`</InternalLink> Replicator flag. [Replicator metrics must be enabled](#set-up-metrics) (with the <InternalLink path="replicator-flags">`--metricsAddr`</InternalLink> flag) in order for metrics snapshotting to work.

  If snapshotting is enabled, the snapshot period must be at least 15 seconds. The recommended range for the snapshot period is 15-60 seconds. The retention policy for metrics snapshot files can be determined by <InternalLink path="replicator-flags">time</InternalLink> and by the <InternalLink path="replicator-flags">total size</InternalLink> of the snapshot data subdirectory. At least one retention policy must be configured. Snapshots can also be <InternalLink path="replicator-flags">compressed to a gzip file</InternalLink>.

  Changing the snapshotter's configuration requires restarting the Replicator binary with different flags.

  ### Enable metrics snapshotting

  #### Step 1. Run Replicator with the snapshot flags

  The following is an example of a `replicator` command where snapshotting is configured:

  ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  replicator start \
  --targetConn postgres://postgres:postgres@localhost:5432/molt?sslmode=disable \
  --stagingConn postgres://root@localhost:26257/_replicator?sslmode=disable \
  --bindAddr 0.0.0.0:30004 \
  --stagingSchema _replicator \
  --stagingCreateSchema \
  --disableAuthentication \
  --tlsSelfSigned \
  --stageMode crdb \
  --bestEffortWindow 1s \
  --flushSize 1000 \
  --metricsAddr :30005 \
  --metricsSnapshotPeriod 15s \
  --metricsSnapshotCompression gzip \
  --metricsSnapshotRetentionTime 168h \
  -v
  ```
</View>

If successful, Replicator will start, and the console output will indicate that the snapshotter has started as well:

```
INFO   [2026-02-02T10:20:32-05:00] Replicator starting
...
INFO   [2026-02-02T10:20:32-05:00] metrics snapshotter started, writing to replicator-data/metrics-snapshots every 15s, retaining 168h0m0s
```

Upon interruption of Replicator, the snapshotter will be stopped:

```
INFO   [2026-02-02T10:26:45-05:00] Interrupted
INFO   [2026-02-02T10:26:45-05:00] metrics snapshotter stopped
INFO   [2026-02-02T10:26:45-05:00] Server shutdown complete
```

#### Step 2. Find the snapshot files in the data directory

You can find the snapshot files in the <InternalLink path="replicator-flags">Replicator data directory</InternalLink>:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
cd replicator-data/metrics-snapshots && ls . | tail -n 5
```

```
snapshot-20260202T152405.737Z.txt.gz
snapshot-20260202T152420.736Z.txt.gz
snapshot-20260202T152435.736Z.txt.gz
snapshot-20260202T152450.735Z.txt.gz
snapshot-20260202T152505.735Z.txt.gz
```

The uncompressed files list the metrics collected at that snapshot:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
gzcat snapshot-20260202T152505.735Z.txt.gz | head -n 3
```

```
# HELP cdc_resolved_timestamp_buffer_size Current size of the resolved timestamp buffer channel which is yet to be processed by Pebble Stager
# TYPE cdc_resolved_timestamp_buffer_size gauge
cdc_resolved_timestamp_buffer_size 0.0 1.770045905735e+09
```

### Bundle and send metrics snapshots

The following requires a Linux system that supports bash.

#### Step 1. Download the export script

Download the [metrics snapshot export script](https://replicator.cockroachdb.com/export-metrics-snapshots.sh). Ensure it's accessible and can be run by the current user.

#### Step 2. Run a snapshot export

Run an export, indicating the `metrics-snapshots` directory within your <InternalLink path="replicator-flags">Replicator data directory</InternalLink>. You can also provide start and end timestamps to define a subset of metrics to bundle. Times are specified as UTC and should be of the format `YYYYMMDDTHHMMSS`.

Running the script without timestamps bundles all of the data in the snapshot directory. For example:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
./export-metrics-snapshots.sh ./replicator-data/metrics-snapshots
```

Running the script with one timestamp bundles all of the data in the snapshot directory beginning at that timestamp. For example:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
./export-metrics-snapshots.sh ./replicator-data/metrics-snapshots 20260115T120000
```

Running the script with two timestamps bundles all of the data in the snapshot directory within the two timestamps. For example:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
./export-metrics-snapshots.sh ./replicator-data/metrics-snapshots 20260115T120000 20260115T140000
```

The resulting output is a `.tar.gz` file placed in the directory from which you ran the script (or to a path specified as an optional argument).

#### Step 3. Upload output file to a support ticket

Include this bundled metrics snapshot file on a <InternalLink version="stable" path="support-resources">support ticket</InternalLink> to give support metrics information that's relevant to your issue.

## See also

* <InternalLink path="molt-replicator">MOLT Replicator</InternalLink>
* <InternalLink path="replicator-flags">Replicator Flags</InternalLink>
* <InternalLink path="molt-replicator-best-practices">MOLT Replicator Best Practices</InternalLink>
* <InternalLink path="molt-replicator-troubleshooting">MOLT Replicator Troubleshooting</InternalLink>
