Kafka Connect InsertHeader SMT Usage Reference for Confluent Cloud or Confluent Platform¶
The following provides usage information for the Apache Kafka® SMT
org.apache.kafka.connect.transforms.InsertHeader
.
Caution
InsertHeader is not currently available for managed connectors.
Description¶
Inserts a header for each record.
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 example above, Connect parses the literal value best-app-ever
into
STRING type.
The following lists sample values for the value property and the data types that
Connect parses the value into:
1234
is parsed into INT16 type.true
is parsed into BOOLEAN type.null
is 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.
Properties¶
Name | Description | Type | Default | Valid Values | Importance |
---|---|---|---|---|---|
header |
Header name to use with the transformation. | string | non-null string | medium | |
value |
The header value to add to each record. If the value appears to be a primitive literal (such as a 32-bit 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 | medium |
Predicates¶
Transformations can be configured with predicates so that the transformation is applied only to records which satisfy a condition. You can use predicates in a transformation chain and, when combined with the Kafka Connect Filter (Kafka) SMT Usage Reference for Confluent Cloud or Confluent Platform, predicates can conditionally filter out specific records. For details and examples, see Predicates.