processor_add_fields processor插件可以添加日志字段。
processor_add_fields processor
Stable
Type
String
是
插件类型。
Fields
Map
待添加字段和字段值。键值对格式,支持添加多个。
IgnoreIfExist
Boolean
否
当Key相同时是否忽略。如果未添加该参数,则默认使用false,表示不忽略。
采集/home/test-log/路径下的test.log文件,并添加字段service: A用于标识日志所在服务。
/home/test-log/
test.log
输入
echo 'this is a test log' >> /home/test-log/test.log
采集配置
enable: true inputs: - Type: input_file FilePaths: - /home/test-log/*.log processors: - Type: processor_add_fields Fields: service: A IgnoreIfExist: false flushers: - Type: flusher_stdout OnlyStdout: true
输出
Last updated 2 years ago
{ "__tag__:__path__": "/home/test_log/key_value.log", "content": "this is a test log", "service": "A", "__time__": "1657354602" }