MaskField is a Kafka Connect single message transform that replaces selected record fields with configured values. In a connector pipeline, it runs alongside transformations such as ValueToKey and ExtractField, with the order controlling the final record. section 5.4
Configure the transform by:
- Adding its name to the connector's comma-separated transforms list. section 5.4
- Selecting org.apache.kafka.connect.transforms.MaskField$Value as its implementation. section 5.4
- Specifying the fields to mask and, when needed, a replacement value. section 5.4
Mask an SSN field
A connector can apply MaskField$Value to the ssn field with the replacement value xxx-xx-xxxx, while earlier transforms copy user_name into the key and extract it from the resulting struct. section 5.4
Listing 5.2 The JSON transform configuration
"transforms":"copyFieldToKey, extractKeyFromStruct, maskSsn", #1
"transforms.copyFieldToKey.type":
"org.apache.kafka.connect.transforms.ValueToKey", #2
"transforms.copyFieldToKey.fields":"user_name", #3
"transforms.extractKeyFromStruct.type":
"org.apache.kafka.connect.transforms.ExtractField$Key", #4
"transforms.extractKeyFromStruct.field":"user_name", #5
"transforms.maskSsn.type":
"org.apache.kafka.connect.transforms.MaskField$Value", #6
"transforms.maskSsn.fields":"ssn", #7
"transforms.maskSsn.replacement":"xxx-xx-xxxx" #8
Inspect the complete JSON transform chain, including transform order, implementation classes, target fields, and the SSN replacement. section 5.4
