键值对

简介

processor_split_key_value processor插件可以通过切分键值对的方式提取字段。

配置参数

样例

采集/home/test-log/路径下的key_value.log文件,并按照键值对间分隔符为制表符,键值对中的分隔符为冒号: 的格式进行日志解析。

  • 输入

echo -e 'class:main\tuserid:123456\tmethod:get\tmessage:\"wrong user\"' >> /home/test-log/key_value.log
  • 采集配置

enable: true
inputs:
  - Type: file_log
    LogPath: /home/test-log/
    FilePattern: key_value.log
processors:
  - Type: processor_split_key_value
    SourceKey: content
    Delimiter: "\t"
    Separator: ":"
flushers:
  - Type: flusher_sls
    Endpoint: cn-xxx.log.aliyuncs.com
    ProjectName: test_project
    LogstoreName: test_logstore
  - Type: flusher_stdout
    OnlyStdout: true
  • 输出

{
    "__tag__:__path__": "/home/test_log/key_value.log",
    "class": "main",
    "userid": "123456",
    "method": "get",
    "message": "\"wrong user\"",
    "__time__": "1657354602"
}

Last updated