添加字段
简介
processor_add_fields processor
插件可以添加日志字段。
配置参数
参数
类型
是否必选
说明
Type
String
是
插件类型。
Fields
Map
是
待添加字段和字段值。键值对格式,支持添加多个。
IgnoreIfExist
Boolean
否
当Key相同时是否忽略。如果未添加该参数,则默认使用false,表示不忽略。
样例
采集/home/test-log/
路径下的test.log
文件,并添加字段service: A用于标识日志所在服务。
输入
echo 'this is a test log' >> /home/test-log/test.log
采集配置
enable: true
inputs:
- Type: file_log
LogPath: /home/test-log/
FilePattern: key_value.log
processors:
- Type: processor_add_fields
Fields:
service: A
IgnoreIfExist: false
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",
"content": "this is a test log",
"service": "A",
"__time__": "1657354602"
}
Last updated