Kafka Connect MaskField SMT for Confluent Platform¶
The following provides usage information for the Apache Kafka® SMT org.apache.kafka.connect.transforms.MaskField
.
Description¶
Can be used for the following scenarios:
- Replace any string or numeric field using the
replacement
property. - Mask specified fields with a valid null value for the following field types:
- Boolean: Boolean.FALSE
- Byte: (byte) 0
- Short: (short) 0
- Integer: 0
- Long: 0L
- Float: Of
- Double: 0d
- BigInteger: BigInteger.ZERO
- BigDecimal: BigDecimal.ZERO
- Date: new Date(0)
- String: “”
Use the concrete transformation type designed for the record key (org.apache.kafka.connect.transforms.MaskField$Key
) or value (org.apache.kafka.connect.transforms.MaskField$Value
).
Examples¶
Mask value¶
This configuration snippet shows how to use MaskField
to mask the value of a
field.
"transforms": "MaskField",
"transforms.MaskField.type": "org.apache.kafka.connect.transforms.MaskField$Value",
"transforms.MaskField.fields": "string_field"
This masks string_field
, transforming the original message as seen
here:
{"integer_field":22, "string_field":"foo"}
into the result here:
{"integer_field":22, "string_field":""}
Replace value¶
This configuration snippet shows how to use MaskField
to replace the value of a field. There are three transformations in the example. The first and second replace a value in a single field. The third is applied to both office
and mobile
phone number fields.
"transforms": "SSNMask", "IPMask", "PhoneMask",
"transforms.SSNMask.type": "org.apache.kafka.connect.transforms.MaskField$Value",
"transforms.SSNMask.fields": "SSN",
"transforms.SSNMask.replacement": "***-***-****",
"transforms.IPMask.type": "org.apache.kafka.connect.transforms.MaskField$Value",
"transforms.IPMask.fields": "IPAddress",
"transforms.IPMask.replacement": "xxx.xxx.xxx.xxx",
"transforms.PhoneMask.type": "org.apache.kafka.connect.transforms.MaskField$Value",
"transforms.PhoneMask.fields": "office,mobile",
"transforms.PhoneMask.replacement": "+0-000-000-0000"
Tip
For additional examples, see Mask Field for managed connectors.
Properties¶
Name | Description | Type | Default | Valid Values | Importance |
---|---|---|---|---|---|
fields |
Names of fields to mask. | list | non-empty list | high | |
replacement |
Custom value replacement applied to all fields values. |
string | null | Non-empty string with a numeric or text value that can be converted to fields type(s). |
low |
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 for Confluent Platform, predicates can conditionally filter out specific records. For details and examples, see Predicates.