Configure Kafka Connect with a custom SMT to mask or hash PII fields before records reach a sink connector

domain: kafka.apache.org · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Implement a Transformation<R extends ConnectRecord<R>> class with apply(), config(), and close() methods and package it as a JAR on the Connect worker plugin path
  2. In apply(), use ConnectRecord.value() to get a Struct (for Avro/JSON Schema) or a Map (for schemaless JSON) and overwrite the PII field with a hash or redaction string
  3. Register the transform in connector config as transforms=maskPii,transforms.maskPii.type=com.example.MaskPiiTransform,transforms.maskPii.fields=email,phone
  4. Chain the custom SMT after ExtractNewRecordState if processing Debezium CDC events so the SMT receives the flattened record rather than the envelope
  5. Use ReplaceField SMT from Kafka Connect's built-in library for simple field renaming or dropping without a custom implementation

Known gotchas

Related routes

Use the Kafka Connect HeaderFrom SMT to promote record value fields into message headers before sink delivery
kafka.apache.org · 6 steps · unrated
Apply Kafka Connect Single Message Transforms for topic routing and field masking
kafka.apache.org · 6 steps · unrated
Configure a Kafka Connect sink connector dead-letter queue with header reporting for failed record diagnosis
kafka.apache.org · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans