.. meta:: :description: This document provides usage information for the Apache Kafka SMT org.apache.kafka.connect.transforms.MaskField. .. _maskfield: ========= MaskField ========= The following provides usage information for the |ak-tm| 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. .. code-block:: json "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. .. code-block:: json "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 ---------- .. list-table:: :header-rows: 1 :widths: 15 20 5 5 20 10 * - 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 .. include:: includes/predicate.rst