0

我正在尝试使用 metricbeat 获取系统指标(metricbeat 5.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 主题持久化中的数据

谁能帮我看看我的配置是否正确?

4

2 回答 2

0

不直接作为静态字符串,不。但是你可以在那里阅读评论......

该设置可以是使用任何事件字段的格式字符串

因此,如果您可以将字段插入到要发送到哪个主题的有效负载中,您可以通过这种方式动态路由数据

于 2018-12-07T05:01:12.323 回答
-2

是的,你可以这么做。基本上你需要在你的探矿者配置中定义。

例如:

文件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
于 2017-01-26T20:36:42.033 回答