CnOps 智能运维与可观测社区
首页开源项目实践文章视频课程常见问答开发者工具STAROps 专题
导航菜单
首页开源项目实践文章视频课程常见问答开发者工具STAROps 专题

CnOps 智能运维与可观测社区

愿景

CnOps 智能运维与可观测社区是一个以"智能运维与可观测"为核心的开放、包容、分享的技术社区,旨在聚集运维专家、开发者和爱好者,共同探讨、学习和分享可观测最佳实践与最新技术,与众多技术社区合作互动,共同探讨交叉领域的技术挑战,推动可观测领域的创新与进步。

内容社区

  • 实践文章
  • 视频课程
  • 开源项目
  • 常见问答
  • 开发者工具

友情链接

  • Prometheus
  • Grafana Lab
  • OpenTelemetry
  • LoongCollector

关注我们

阿里云云原生公众号阿里云云原生
阿里云可观测公众号阿里云可观测

Copyright © 2026 CnOps 社区. All rights reserved.

首页/开源项目/LoongCollector/数据脱敏
文档目录
概览版本管理
什么是处理插件
添加字段追加字段添加云资产信息原始数据数据脱敏字段值映射处理丢弃字段字段加密条件字段处理日志过滤时间提取(Go 时间格式)GrokJson日志转SLS Metricotel Metric格式转换otel Trace格式转换字段打包日志限速正则重命名字段分隔符键值对多行切分字符串替换时间提取(strptime 格式)

LoongCollector

数据脱敏

processordesensitize插件可以通过正则表达式匹配并实现文本日志中敏感数据的脱敏。源代码 Beta 推荐版本:iLogtail v1.6.0 及以上 | 参数 | 类型,默认值 | 说明 | | - | - | - | | Type | string,无默认值(必填) | 插件类型,固定为processordesensitize | |...

数据脱敏

简介

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

版本

Beta

版本说明

  • 推荐版本:iLogtail v1.6.0 及以上

配置参数

参数 类型,默认值 说明
Type string,无默认值(必填) 插件类型,固定为processor_desensitize
SourceKey string,无默认值(必填) 日志字段名称。
Method string,无默认值(必填) 脱敏方式。可选值如下:
const:将敏感内容替换成 ReplaceString 参数处配置等字符串。
md5:将敏感内容替换为其对应的MD5值。
Match string,无默认值(必填) 指定敏感数据。可选值如下:
full:字段全文。
regex:使用正则提取敏感数据。
ReplaceString string,无默认值 用于替换敏感内容等字符串,当 Method 设置为 const 时必选。
RegexBegin string,无默认值 用于指定敏感内容前缀的正则表达式,当 Match 配置为 regex 时必选。
RegexContent string,无默认值 用于指定敏感内容的正则表达式,当 Match 配置为 regex 时必选。

样例

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

  • 输入
echo "[{'account':'1812213231432969','password':'04a23f38'}, {account':'1812213685634','password':'123a'}]" >> /home/test-loongcollector/test-log/processor-desensitize.log
  • 采集配置1
enable: true
inputs:
  - Type: input_file
    FilePaths: 
      - /home/test-log/*.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: input_file
    FilePaths: 
      - /home/test-log/*.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: input_file
    FilePaths: 
      - /home/test-log/*.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'}]"
}

文章大纲