metricbeat输出Kafka配置

km0tfn4u  于 2021-06-07  发布在  Kafka
关注(0)|答案(2)|浏览(465)

我正在尝试使用metricbeat(MetricBeat5.1.1)获取系统度量,并将数据输出到kafka主题

output.kafka:
  # Boolean flag to enable or disable the output module.
  enabled: true

  # The list of Kafka broker addresses from where to fetch the cluster metadata.
  # The cluster metadata contain the actual Kafka brokers events are published
  # to.
  hosts: ["XX.XXX.XXX.XX:9092","XX.XXX.XXX.XX:9092","XX.XXX.XXX.XX:9092"]
  # The Kafka topic used for produced events. The setting can be a format string
  # using any event field. To set the topic from document type use `%{[type]}`.
  topic: ab-mb-raw, cd-mb-raw

有没有可能把数据推到Kafka的不止一个主题上?
当我运行上述配置时,我无法看到Kafka主题中的数据
有人能帮我确定我的配置是否正确吗?

jslywgbw

jslywgbw1#

不是直接作为一个静态字符串,不是。但是你可以阅读那里的评论。。。
设置可以是使用任何事件字段的格式字符串
因此,如果可以在要发送到哪个主题的有效负载中插入一个字段,则可以通过这种方式动态路由数据

rnmwe5a2

rnmwe5a22#

是的,你能做到。基本上,您需要在浏览配置中定义。
例如:
主文件beat.yml:

output.kafka:
  hosts: ["kafka:9092"]
  topic: "%{[type]}"   <----- that is what you need.
  compression: snappy

# Prospector configs

filebeat.config_dir: /opt/filebeat/etc/conf.d

您在/opt/filebeat/etc/conf.d中的浏览者可以在文件中显示如下内容:

filebeat.prospectors:
  - input_type: log
paths:
  - "test.log"
document_type: "topic_name" <--------- topic per prospector

相关问题