Monitoring is only available for that emit messages to a .
- retryable: The changefeed will automatically retry whatever caused the error. (You may need to intervene so that the changefeed can resume.)
- non-retryable: The changefeed has encountered a terminal error and fails.
- When the changefeed cannot verify the target table’s schema. For example, the table is offline or there are types within the table that the changefeed cannot handle.
- The changefeed cannot convert the data to the specified . For example, there are types that changefeeds do not support, or a is using an unsupported or malformed expression.
- The terminal error happens as part of established changefeed behavior. For example, you have specified the and a schema change happens.
Monitor a changefeed
Changefeed progress is exposed as a that advances as the changefeed progresses. This is a guarantee that all changes before or at the timestamp have been emitted. You can monitor a changefeed:- On the of the DB Console.
- On the of the DB Console. Hover over the high-water timestamp column to view the .
-
Using
SHOW CHANGEFEED JOB <job_id>: - Using Prometheus and Alertmanager to track and alert on changefeed metrics. See the tutorial for steps to set up Prometheus. See the Recommended changefeed metrics to track section for the essential metrics to alert you when a changefeed encounters a retryable error, or enters a failed state.
You can use the high-water timestamp to .
Recommended changefeed metrics to track
By default, changefeeds will retry errors with some exceptions. We recommend setting up monitoring for the following metrics to track retryable errors to avoid an over-accumulation of garbage, and non-retryable errors to alert on changefeeds in a failed state:changefeed.max_behind_nanos: When a changefeed’s high-water mark timestamp is at risk of falling behind the cluster’s .changefeed.error_retries: The total number of retryable errors encountered by all changefeeds.changefeed.failures: The total number of changefeed jobs that have failed.
Protected timestamp and garbage collection monitoring
will protect changefeed data from garbage collection in particular scenarios, but if a changefeed lags too far behind, the protected changes could cause data storage issues. Refer to for detail on when changefeed data is protected from garbage collection. You can monitor changefeed jobs for usage. We recommend setting up monitoring for the following metrics:jobs.changefeed.protected_age_sec: Tracks the age of the oldest record protected by changefeed jobs. We recommend monitoring ifprotected_age_secis greater than . Asprotected_age_secincreases, garbage accumulation increases. will not progress on a table, database, or cluster if the protected timestamp record is present.jobs.changefeed.currently_paused: Tracks the number of changefeed jobs currently considered . Since paused changefeed jobs can accumulate garbage, it is important to .jobs.changefeed.expired_pts_records: Tracks the number of expired records owned by changefeed jobs. You can monitor this metric in conjunction with the .jobs.changefeed.protected_record_count: Tracks the number of records held by changefeed jobs.
Schema registry metrics
If you are running a changefeed with the option, set up monitoring for the following metrics:changefeed.schema_registry.retry_count: The number of retries encountered when sending requests to the schema registry. A non-zero value could indicate incorrect configuration of the schema registry or changefeed parameters.changefeed.schema_registry.registrations: The number of registration attempts with the schema registry.
Using changefeed metrics labels
To measure metrics per changefeed, you can define a “metrics label” for one or multiple changefeed(s). The changefeed(s) will increment each . Metrics label information is sent with time-series metrics tohttp://{host}:{http-port}/_status/vars, viewable via the . An aggregated metric of all changefeeds is also measured.
It is necessary to consider the following when applying metrics labels to changefeeds:
- The
server.child_metrics.enabledmust be set totruebefore using themetrics_labeloption.server.child_metrics.enabledis enabled by default in Standard and Basic. - Metrics label information is sent to the
_status/varsendpoint, but will not show up in or the . - Introducing labels to isolate a changefeed’s metrics can increase cardinality significantly. There is a limit of 1024 unique labels in place to prevent cardinality explosion. That is, when labels are applied to high-cardinality data (data with a higher number of unique values), each changefeed with a label then results in more metrics data to multiply together, which will grow over time. This will have an impact on performance as the metric-series data per changefeed quickly populates against its label.
- The maximum length of a metrics label is 128 bytes.
true:
metrics_label option with the label name as its value:
http://{host}:{http-port}/_status/vars shows the defined changefeed(s) by label and the aggregated metric for all changefeeds. This output also shows the default scope, which will include changefeeds started without a metrics label:
Metrics
| Metric | Description | Unit | Type |
|---|---|---|---|
changefeed.admit_latency | Difference between the event’s MVCC timestamp and the time the event is put into the memory buffer. | Nanoseconds | Histogram |
changefeed.aggregator_progress | The earliest timestamp up to which any is guaranteed to have emitted all values for which it is responsible. Note: This metric may regress when a changefeed restarts due to a transient error. Consider tracking the changefeed.checkpoint_progress metric, which will not regress. | Timestamp | Gauge |
changefeed.backfill_count | Number of changefeeds currently executing a backfill ( or initial scan). | Changefeeds | Gauge |
changefeed.backfill_pending_ranges | Number of in an ongoing backfill that are yet to be fully emitted. | Ranges | Gauge |
changefeed.checkpoint_hist_nanos | Time spent checkpointing changefeed progress. | Nanoseconds | Histogram |
changefeed.checkpoint_progress | The earliest timestamp of any changefeed’s persisted checkpoint (values prior to this timestamp will never need to be re-emitted). | Timestamp | Histogram |
changefeed.commit_latency | Difference between the event’s MVCC timestamp and the time it is acknowledged by the . If the sink is batching events, then the difference is between the oldest event and when the acknowledgment is recorded. | Nanoseconds | Histogram |
changefeed.emitted_batch_sizes | Size of batches emitted to the sink by all changefeeds. If changefeeds have the option enabled, this metric will include resolved timestamp messages, which emit in a batch size of 1 message. | Messages | Histogram |
changefeed.emitted_bytes | Number of bytes emitted, which increments as messages are flushed. | Bytes | Counter |
changefeed.emitted_messages | Number of messages emitted, which increments when messages are flushed. | Messages | Counter |
changefeed.error_retries | Total retryable errors encountered by changefeeds. | Errors | Counter |
changefeed.flushed_bytes | Bytes emitted by all changefeeds. This may differ from emitted_bytes when is enabled. | Bytes | Counter |
changefeed.flush_hist_nanos | Time spent flushing messages across all changefeeds. | Nanoseconds | Histograms |
changefeed.flushes | Total number of flushes for a changefeed. | Flushes | Counter |
changefeed.lagging_ranges | Number of ranges which are behind in a changefeed. This is calculated based on the options:
lagging_ranges_threshold duration are considered to be lagging. Starting a changefeed with an initial scan on a large table will likely increment the metric for each range in the table. As ranges complete the initial scan, the number of ranges lagging behind will decrease. | Nanoseconds | Gauge |
Note: Ranges undergoing an for longer than the lagging_ranges_threshold duration are considered to be lagging. Starting a changefeed with an initial scan on a large table will likely increment the metric for each range in the table. As ranges complete the initial scan, the number of ranges lagging behind will decrease. | Nanoseconds | Gauge | |
changefeed.message_size_hist | Distribution in the size of emitted messages. | Bytes | Histogram |
changefeed.running | Number of currently running changefeeds, including sinkless changefeeds. | Changefeeds | Gauge |
changefeed.sink_batch_hist_nanos | Time messages spend batched in the sink buffer before being flushed and acknowledged. | Nanoseconds | Histogram |
changefeed.total_ranges | Total number of ranges that are watched by participating in the changefeed job. changefeed.total_ranges shares the same polling interval as the changefeed.lagging_ranges metric, which is controlled by the lagging_ranges_polling_interval option. For more details, refer to Lagging ranges. |
Monitoring and measuring changefeed latency
Changefeeds can encounter latency in events processing. This latency is the total time CockroachDB takes to:- Commit writes to the database.
- Encode .
- Deliver the message to the .
- Event latency: Measure the difference between an event’s MVCC timestamp and when it is put into the memory buffer or acknowledged at the sink.
- Lagging ranges: Track the number of that are behind in a changefeed.
Event latency
To monitor for changefeeds encountering latency in how events are emitting, track the following metrics:admit_latency: The difference between the event’s MVCC timestamp and the time the event is put into the memory buffer.commit_latency: The difference between the event’s MVCC timestamp and the time it is acknowledged by the . If the sink is batching events, the difference is between the oldest event and when the acknowledgment is recorded.
The
admit_latency and commit_latency metrics do not update for backfills during or . This is because a full table scan may contain rows that were written far in the past, which would lead to inaccurate changefeed latency measurements if the events from these scans were included in admit_latency adn commit_latency.metrics_label option when starting a changefeed to differentiate metrics per changefeed.
We recommend using the p99 commit_latency aggregation for alerting and to set SLAs for your changefeeds. Refer to the Commit Latency graph to track this metric in the .
If your changefeed is experiencing elevated latency, you can use these metrics to:
- Review
admit_latencyversuscommit_latencyto calculate the time events are moving from the memory buffer to the downstream sink. - Compare the
commit_latencyP99, P90, P50 latency percentiles to investigate performance over time.
Lagging ranges
Use thechangefeed.lagging_ranges metric to track the number of that are behind in a changefeed. This is calculated based on the :
lagging_ranges_thresholdsets a duration from the present that determines the length of time a range is considered to be lagging behind, which will then track in the metric. Note that ranges undergoing an for longer than the threshold duration are considered to be lagging. Starting a changefeed with an initial scan on a large table will likely increment the metric for each range in the table. As ranges complete the initial scan, the number of ranges lagging behind will decrease.- Default:
3m
- Default:
lagging_ranges_polling_intervalsets the interval rate for when lagging ranges are checked and thelagging_rangesmetric is updated. Polling adds latency to thelagging_rangesmetric being updated. For example, if a range falls behind by 3 minutes, the metric may not update until an additional minute afterward.- Default:
1m
- Default:
changefeed.total_ranges metric to monitor the number of ranges that are watched by participating in the changefeed job. If you’re experiencing lagging ranges, changefeed.total_ranges may indicate that the number of ranges watched by aggregator processors in the job is unbalanced. You may want to try the changefeed and then it, so that the changefeed replans the work in the cluster. changefeed.total_ranges shares the same polling interval as the changefeed.lagging_ranges metric, which is controlled by the lagging_ranges_polling_interval option.
Debug a changefeed
Using logs
For changefeeds, to debug connection issues (i.e.,kafka: client has run out of available brokers to talk to (Is your cluster reachable?)). Debug by looking for lines in the logs with [kafka-producer] in them:
Using SHOW CHANGEFEED JOBS
For changefeeds, use SHOW CHANGEFEED JOBS to check the status of your changefeed jobs:
Using the DB Console
On the of the DB Console:- To add a chart, click Add Chart.
-
Select
changefeed.error_retriesfrom the Metric Name dropdown menu. A graph of changefeed restarts due to retryable errors will display.

