filebeat导向kafka多topic之前使用filebeat去行读取GC日志,没有使用多行合并,配置如下:
# pattern支持正则表达式,很爽
multiline.pattern: '^\[.+\]'
multiline.negate: true
multiline.match: "after"negate和match组合合并多行日志有很好的说明,记得文档一定坚持看完kafka多topicfields自定义字段及值,会在output输出时会做为map形式输出,在codec.string中可以使用%{[]}调用
容器中需要读取GC及Log4j产生的日志,在kafka端想创建两个独立的topic,不想共用同topic这时需要filebeat动态支持根据fields定义字段切换topic,配置如下:
filebeat:
prospectors:
- type: log
paths:
- /data/logs/gc.log
close_rename: true
fields:
logResource: "fuck-log"
tail_files: true
- type: log
enabled: true
paths:
- /data/logs/${APP_NAME}/*.log
fields:
appName: ${APP_NAME}
logResource: "shit-log"
### Multiline options
multiline.pattern: '^\[.+\]'
multiline.negate: true
multiline.match: "after"
tail_files: true
registry_file: /var/lib/filebeat/registry/registry
#================================ kafka =====================================
output.kafka:
hosts: ["x.x.x.x:9092"]
topic: "%{[fields.logResource]}"
partition.round_robin:
reachable_only: false
required_acks: 1
compression: gzipfields.logResource在不同input根据业务配置名称topic: "%{[fields.logResource]}"输出端配置自定义字段,filebeat output阶段获取输出对象中自定义值给topic赋值,因为topic获取的就是字符串原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。