在 Kafka Connect 日志中屏蔽?

Masking in Kafka Connect logs?

我需要知道 Kafka 中的秘密是如何被掩盖的。秘密就像用户名、密码、serviceID 和 apiKey 等等。我不想记录此类信息。

对于 you can use secrets externalization. This feature was implemented in 2.0.0 through KIP-297


简短示例:

  1. 将这些属性添加到 connect-distributed.properties 文件:
config.providers=file
config.providers.file.class=org.apache.kafka.common.config.provider.FileConfigProvider
  1. 创建包含敏感信息的文件(例如/secrets/postgres.properties):

    password=strongestPasswordEver

  2. 现在您可以在连接器配置中使用占位符,例如:

    "database.password": "${file:/secrets/postgres.properties:password}"

在这里,占位符 ${file:/secrets/postgres.properties:user} 表示应该使用文件配置提供程序,读取 属性 文件 /secrets/postgres.properties 并从中提取用户 属性。


好文章:

  1. Putting Kafka Connect passwords in a separate file / externalising secrets
  2. Secrets externalization with Debezium connectors

不清楚您记录的是什么数据。

Slf4j 具有可自定义的输出格式。 MDC 上下文日志记录最近被添加到连接器记录器中,但它取决于您自己的代码逻辑来屏蔽敏感数据。

注意:Kafka 本身也不进行静态加密