Kafka Connect InsertHeader SMT Usage Reference for Confluent Platform
The InsertHeader SMT (org.apache.kafka.connect.transforms.InsertHeader)
adds a header with a literal value to each Apache Kafka® record.
Description
Use InsertHeader to add a header with a fixed literal value to every
record. Connect parses the literal into the corresponding data type based
on its format (for example, 1234 becomes an integer and true becomes a
boolean).
Properties
Name |
Description |
Type |
Default |
Valid values |
Importance |
|---|---|---|---|---|---|
|
Header name to use with the transformation. |
string |
non-null string |
high |
|
|
The header value to add to each record. If the value appears to be a primitive literal (such as an integer, boolean, or null) or a complex literal (such as an array or map denoted with JSON-like syntax), the value is parsed and added to the header as that type. Otherwise, the raw string for this property is used as-is. |
string |
non-null string |
high |
Example
This configuration snippet shows how to use InsertHeader to insert a header
named app.id with the literal value best-app-ever on each record.
"transforms": "insertAppIdHeader",
"transforms.insertAppIdHeader.type": "org.apache.kafka.connect.transforms.InsertHeader",
"transforms.insertAppIdHeader.header": "app.id",
"transforms.insertAppIdHeader.value.literal": "best-app-ever"
Before: No header named app.id or value in records.
After: Each record contains header value best-app-ever.
In the preceding example, Connect parses the literal value best-app-ever
into STRING type.
The following lists sample values for the value.literal property and the
data types that Connect parses the value into:
1234is parsed into INT16 type.trueis parsed into BOOLEAN type.nullis parsed into null (with no type).[-3, 0, 5]is parsed into an ARRAY of INT8 elements.{3.4: 4761, -5.9: -9753186420}is parsed into a MAP with FLOAT32 keys and INT64 values.
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.