数据脱敏

简介

processor_desensitize插件可以通过正则表达式匹配并实现文本日志中敏感数据的脱敏。源代码

配置参数

样例

采集/home/test-ilogtail/test-log/路径下包含敏感数据的processor-desensitize.log文件,根据指定的配置选项提取日志信息。

  • 输入

echo "[{'account':'1812213231432969','password':'04a23f38'}, {account':'1812213685634','password':'123a'}]" >> /home/test-ilogtail/test-log/processor-desensitize.log
  • 采集配置1

enable: true
inputs:
  - Type: file_log
    LogPath: /home/test-ilogtail/test-log/
    FilePattern: processor-desensitize.log
processors:
  - Type: processor_desensitize
    SourceKey: content
    Method: "const"
    Match: "full"
    ReplaceString: "********"
flushers:
  - Type: flusher_stdout
    OnlyStdout: true
  • 输出1

{
  "content":"********",
}
  • 采集配置2

enable: true
inputs:
  - Type: file_log
    LogPath: /home/test-ilogtail/test-log/
    FilePattern: processor-desensitize.log
processors:
  - Type: processor_desensitize
    SourceKey: content
    Method: "const"
    Match: "regex"
    ReplaceString: "********"
    RegexBegin: "'password':'"
    RegexContent: "[^']*"
flushers:
  - Type: flusher_stdout
    OnlyStdout: true
  • 输出2

{
  "content":"[{'account':'1812213231432969','password':'********'}, {'account':'1812213685634','password':'********'}]",
}
  • 采集配置3

enable: true
inputs:
  - Type: file_log
    LogPath: /home/test-ilogtail/test-log/
    FilePattern: processor-desensitize.log
processors:
  - Type: processor_desensitize
    SourceKey: content
    Method: "md5"
    Match: "regex"
    ReplaceString: "********"
    RegexBegin: "'password':'"
    RegexContent: "[^']*"
flushers:
  - Type: flusher_stdout
    OnlyStdout: true
  • 输出3

{
  "content":"[{'account':'1812213231432969','password':'9c525f463ba1c89d6badcd78b2b7bd79'}, {'account':'1812213685634','password':'1552c03e78d38d5005d4ce7b8018addf'}]",
}

Last updated