Offset mapping
Translate consumer group positions to the target cluster.
Kafka stores consumer positions relative to each cluster's partition log. The offset where an application stopped on the source Kafka cluster has no meaning on the target Kafka cluster. Without translation, failover would force consumers to reprocess from the beginning.
K2K records source-target-Kafka-cluster offset mappings as it replicates, then the offset mapper translates committed consumer group positions on the target Kafka cluster. Both applications share the same pipeline file; see Deployment. Rather than reading __consumer_offsets directly, K2K polls group metadata through the admin API, which supports managed offerings where internal topics are not exposed. For topic provisioning, see Topic creation. For polling, retention, and error handling, see the Advanced section below.
Deployment
Offset mapping requires both K2K applications running with the same pipeline file:
K2K replicator
k2k start
Records source-to-target offset mappings as it replicates
K2K offset mapper
k2k-offset-mapping start
Translates consumer group positions on the target Kafka cluster
Start both applications with the same pipeline file:
k2k start -f my_pipeline.yml
k2k-offset-mapping start -f my_pipeline.ymlKeep both processes running continuously. Enabling features.offsetMapping in the pipeline file alone does not translate consumer offsets. See Deployment.
Prerequisites
License accepted, with a token carrying the offset mapping entitlement
Topic selection and data routing configured with
partition: sourcetarget.kafka.consumer."group.id"set — the offset mapper joins a consumer group on the target Kafka cluster to read the mapping topicfeatures.offsetMapping: enabledin the pipelineReplicator running (
k2k start) with the pipeline aboveOffset mapper running (
k2k-offset-mapping start) with the same pipeline file
Example
Use the following pipeline configuration:
target.kafka.consumer."group.id" is what the offset mapper uses to join a consumer group on the target Kafka cluster and read the mapping topic. It is unrelated to source.kafka.consumer."group.id", which is the K2K group the replicator uses. All offset mapper instances for a pipeline must share it — see Horizontal scaling.
Start both applications from the same pipeline file:
Configuration keys
Feature toggle
features.offsetMapping
Record offset mappings during replication for consumer group translation
No
disabled
Replicator
Both the replicator and the offset mapper check the offset mapping entitlement, so a token without it fails both applications at startup.
Connection keys
target.kafka.consumer."group.id"
Consumer group the offset mapper joins to read the offset mapping topic
Yes
(none)
Offset mapper
groups.consumerGroups
Consumer groups on the source Kafka cluster to translate (regex or list)
Conditional
.*
Offset mapper
Advanced
Offset mapping topic
offsetMapping.topic
Topic storing source-Kafka-cluster-to-target-Kafka-cluster offset mappings on the target Kafka cluster
No
__k2k_offset_mappings
Both
For auto creating this topic with custom settings, see Topic creation.
Mappings guard
features.applyMappingsGuard
Skip applying offset mappings when the target Kafka cluster already has a more recent committed offset
No
enabled
Offset mapper
The guard is on by default. The offset mapper checks committed offsets on the target Kafka cluster before applying a translation; if the target group already has a newer position, the mapping is skipped to avoid moving consumers backwards. Set it to disabled only when you want translations applied unconditionally.
Polling and group selection
groups.consumerGroups
Consumer groups on the source Kafka cluster to translate (regex string or list of group names)
Conditional
.*
Offset mapper
groups.pollInterval
How often to poll the source Kafka cluster for consumer group changes
No
5 seconds
Offset mapper
On each poll, K2K lists consumer groups on the source Kafka cluster and fetches their committed offsets through the admin API. This avoids depending on direct access to internal __consumer_offsets topics, which some managed Kafka vendors do not expose.
groups.consumerGroups accepts two forms. A regex string matches group names by pattern:
A YAML list names groups exactly, which is the safer choice for a controlled failover where only specific applications should be translated:
Retention
offsetMapping.retention.time
How long to retain mapping ranges (topic, infinite, or a duration)
No
topic
Offset mapper
offsetMapping.retention.count
Mapping ranges to retain per topic partition (integer or infinite)
No
1000
Offset mapper
offsetMapping.retention.schedule
How often the retention process runs
No
5 minutes
Offset mapper
Retention controls how many historical cross-cluster offset ranges K2K keeps on the target Kafka cluster. Older ranges are removed so the mapping topic does not grow without bound.
retention.time accepts topic (follow the mapping topic's own retention), infinite (never evict by age), or a duration such as 7 days. retention.count accepts an integer or infinite (never evict by count). Both limits apply together — a range is evicted when it exceeds either one.
Watermark prefix
groups.offsetGuardPrefix
Prefix for watermark entries written to consumer groups on the target Kafka cluster
No
k2k_
Offset mapper
K2K writes watermark offsets to the target Kafka cluster under synthetic topic names prefixed with this value. The offset mapper uses these watermarks to detect when a target consumer group already has a more recent position than a pending translation.
Error handling
errorHandling.onMultipleTargetCommittedOffsets
Action when multiple committed offsets exist for the same group on the target Kafka cluster
No
fail
Offset mapper
errorHandling.onActiveConsumerGroupCommit
Action when committing offsets for a group with active consumers on the target Kafka cluster
No
fail
Offset mapper
onMultipleTargetCommittedOffsets applies when the target Kafka cluster reports more than one committed offset for the same group and partition. onActiveConsumerGroupCommit applies when the offset mapper would commit offsets for a group with active consumers on the target Kafka cluster.
Last updated
Was this helpful?

