简介
processor_split_key_value processor
插件可以通过切分键值对的方式提取字段。
版本
Stable
配置参数
样例
切分键值对1
采集/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"
}
包含引用符的切分键值对
采集/home/test-log/
路径下的key_value.log
文件,并按照键值对间分隔符为制表符,键值对中的分隔符为冒号:
的格式进行日志解析。
echo -e 'class:main http_user_agent:"User Agent" "中文" "hello\t\"ilogtail\"\tworld"' >> /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: " "
Separator: ":"
Quote: "\""
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",
"http_user_agent": "User Agent",
"no_separator_key_0": "中文",
"no_separator_key_1": "hello\t\"ilogtail\"\tworld",
"__time__": "1657354602"
}
包含多字符引用符的切分键值对
采集/home/test-log/
路径下的key_value.log
文件,并按照键值对间分隔符为制表符,键值对中的分隔符为冒号:
的格式进行日志解析。
echo -e 'class:main http_user_agent:"""User Agent""" """中文"""' >> /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: " "
Separator: ":"
Quote: "\"\"\""
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",
"http_user_agent": "User Agent",
"no_separator_key_0": "中文",
"__time__": "1657354602"
}
Last updated