同一份日志想要输出到kafka多个topic,该如何实现?

寻源 发表于: 2022-02-18   最后更新时间: 2022-02-18 15:47:22   945 游览

kafka_2.12_2.2.0版本的集群,采集用的容器部署的filebeat。

客户申请想要将同一目录下的所有日志输出到不同的三个topic,请问可以实现么 ,相关的设置有哪些需要注意的呢?

发表于 2022-02-18
添加评论

可以实现,通过topics,以下是一个例子:

output.kafka:
  hosts: ["localhost:9092"]
  topic: "logs-%{[agent.version]}"
  topics:
    - topic: "critical-%{[agent.version]}"
      when.contains:
        message: "CRITICAL"
    - topic: "error-%{[agent.version]}"
      when.contains:
        message: "ERR"

参考来自官方文章:https://www.elastic.co/guide/en/beats/filebeat/master/kafka-output.html#topics-option-kafka

你的答案

查看kafka相关的其他问题或提一个您自己的问题