Kafka Connect TimestampRouter SMT Usage Reference for Confluent Platform

The TimestampRouter SMT (org.apache.kafka.connect.transforms.TimestampRouter) updates an Apache Kafka® record’s topic field based on the original topic value and the record timestamp.

Description

TimestampRouter updates a record’s topic field using the record timestamp. This is useful for sink connectors, because the topic field often determines the equivalent entity name in the destination system such as a database table or search index name.

To extract the timestamp from a specified message field, see Kafka Connect MessageTimestampRouter SMT Usage Reference for Confluent Platform. To convert the format of a timestamp field, see Kafka Connect TimestampConverter SMT Usage Reference for Confluent Platform.

Properties

Name

Description

Type

Default

Valid values

Importance

timestamp.format

Format string for the timestamp that is compatible with java.text.SimpleDateFormat. For additional details, see SimpleDateFormat.

string

yyyyMMdd

high

topic.format

Format string which can contain ${topic} and ${timestamp} as placeholders for the topic and timestamp, respectively.

string

${topic}-${timestamp}

high

Example: Add a timestamp to the topic

This configuration snippet shows how to use TimestampRouter to route messages to topics and include a formatted timestamp.

"transforms": "TimestampRouter",
"transforms.TimestampRouter.type": "org.apache.kafka.connect.transforms.TimestampRouter",
"transforms.TimestampRouter.topic.format": "foo-${topic}-${timestamp}",
"transforms.TimestampRouter.timestamp.format": "YYYYMM"

Before: ordersTopic

After: foo-ordersTopic-201804

Predicates

Configure transformations with predicates to ensure they process only records that satisfy a particular condition. You can also use predicates in a transformation chain with the Kafka Connect Filter (Kafka) SMT Usage Reference for Confluent Platform to conditionally filter specific records. For more information, see Predicates.