Kafka Connect HeaderFrom SMT Usage Reference for Confluent Platform
The following provides usage information for the Apache Kafka® SMT org.apache.kafka.connect.transforms.HeaderFrom.
Description
Moves or copies fields in a record key or value into the record’s header. Use the concrete transformation type designed for the record key (org.apache.kafka.connect.transforms.HeaderFrom$Key) or value (org.apache.kafka.connect.transforms.HeaderFrom$Value).
Example
This configuration snippet shows how to use HeaderFrom to move the fields id and ts in the record’s value into the record header. The transform removes the fields from the record value. If you want to keep the fields in the record value, use the operation copy instead of move.
"transforms": "moveFieldsToHeader",
"transforms.moveFieldsToHeader.type": "org.apache.kafka.connect.transforms.HeaderFrom$Value",
"transforms.moveFieldsToHeader.fields": "id,ts",
"transforms.moveFieldsToHeader.headers": "record_id,event_timestamp",
"transforms.moveFieldsToHeader.operation": "move"
Before:
Record value
{ "id": 24, "ts": 1626102708861, "name": "John Smith", "book": "Kafka: The Definitive Guide" }
Record header
{ "source": "RedditSource" }
After:
Record value
{ "name": "John Smith", "book": "Kafka: The Definitive Guide" }
Record header
{ "source": "RedditSource", "record_id": 24, "event_timestamp": 1626102708861, }
Properties
All properties are required.
Name | Description | Type | Default | Valid Values | Importance |
|---|---|---|---|---|---|
| A comma-separated list of field names that the transform moves or copies to the record header. | list | non-empty list | high | |
| A comma-separated list of header names. The number of | list | non-empty list | high | |
| The | string |
| high |
Predicates
Configure transformations with predicates to ensure they only process records satisfying a particular condition. You can also use predicates in a transformation chain along with the Kafka Connect Filter (Kafka) SMT Usage Reference for Confluent Platform to conditionally filter specific records. For more information, refer to Predicates.