InsertHeader

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:

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 Filter (Apache Kafka), predicates can conditionally filter out specific records. For details and examples, see Predicates.