我是靠谱客的博主 壮观日记本,最近开发中收集的这篇文章主要介绍一个filebeat实例 设置多topic设置,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

 

方法1:一实例多topic:

https://discuss.elastic.co/t/filebeat-5-0-output-to-kafka-multiple-topics/67934

 

The document_type per prospector becomes the event field type. That's why the filter won't match.
Instead of conditionals consider using the format string like:
filebeat.prospectors: - ... document_type: myapp_applog - ... document_type: myapp_applog_stats - ... document_type: myapp_elblog output.kafka: topic: '%{[type]}' # use document_type to set topic

btw. the topic field in conditionals also supports format strings.

 

 

cat filebeat.yml

output.kafka: enabled: true hosts: ["192.168.111.107:9092","192.168.111.108:9092","192.168.111.109:9092"] topic: '%{[type]}' filebeat.prospectors: #------------------------------ Log prospector -------------------------------- - paths: - /data/logs/financial-manager/server0.log fields: app_id: financial-manager multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}s(20|21|22|23|[0-1]d):[0-5]d:[0-5]d.' multiline.negate: true multiline.match: after document_type: log-log4j - paths: - /data/logs/user-service/*.log fields: app_id: user-service multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}s(20|21|22|23|[0-1]d):[0-5]d:[0-5]d.' multiline.negate: true multiline.match: after document_type: log-iis - paths: - /data/logs/financial-manager/access_log.log fields: app_id: financial-manager document_type: log-undertow

 

 

方法二:多filebeat实例,每个filebeat实例设置一个topic

运行多个filebeat实例,每个实例对应一个配置文件

cat filebeat.yml
output.kafka:
enabled: true
hosts: ["192.168.111.107:9092","192.168.111.108:9092","192.168.111.109:9092"]
topic: log-log4j
filebeat.prospectors:
#------------------------------ Log prospector --------------------------------
- paths:
- /data/logs/subscribe-consumer/server0.log
fields:
app_id: subscribe-consumer
multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}s(20|21|22|23|[0-1]d):[0-5]d:[0-5]d.'
multiline.negate: true
multiline.match: after

 

cat filebeat2.yml
output.kafka:
enabled: true
hosts: ["192.168.111.107:9092","192.168.111.108:9092","192.168.111.109:9092"]
topic: log-tomcat
filebeat.prospectors:
#------------------------------ Log prospector --------------------------------
- paths:
- /data/logs/subscribe-consumer/server0.log
fields:
app_id: subscribe-consumer
multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}s(20|21|22|23|[0-1]d):[0-5]d:[0-5]d.'
multiline.negate: true
multiline.match: after

 

转载于:https://www.cnblogs.com/linkenpark/p/7694159.html

最后

以上就是壮观日记本为你收集整理的一个filebeat实例 设置多topic设置的全部内容,希望文章能够帮你解决一个filebeat实例 设置多topic设置所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(38)

评论列表共有 0 条评论

立即
投稿
返回
顶部