简体   繁体   English

将 UDP 消息推送到 Kafka 主题

[英]Pushing UDP messages to Kafka topic

Is it possible for kafka producer to listen on certain ports ( UDP/TCP ) and then send that data to specified topic. kafka 生产者是否可以侦听某些端口( UDP/TCP ),然后将该数据发送到指定的主题。

Do i need to develop a separate daemon which listens on the port and then send the data to kafka topic ?我是否需要开发一个单独的守护进程来监听端口,然后将数据发送到 kafka 主题? ( There are already a few github project available). (已经有几个 github 项目可用)。 Just wanted to make sure that we already a way to do it so that it becomes more robust and easy to scale.只是想确保我们已经有办法做到这一点,以便它变得更加健壮和易于扩展。 BAsically, relaying UDP packets into Kafka基本上,将 UDP 数据包中继到 Kafka

Regards Sunil问候苏尼尔

As mentioned in comments, yes it is possible - several solutions can be found by doing a google search - here is one project, that lets you do what you want to do - out of the box:正如评论中提到的,是的,这是可能的——通过谷歌搜索可以找到几种解决方案——这是一个项目,它可以让你做你想做的事情——开箱即用:

https://github.com/agaoglu/udp-kafka-bridge https://github.com/agaoglu/udp-kafka-bridge

I would preferred to use rsyslogd: /etc/rsyslog.d/kafka.conf我更喜欢使用 rsyslogd:/etc/rsyslog.d/kafka.conf

module(load="imudp")
module(load="omkafka")

template(name="kafka_msg" type="string" string="%msg%")

ruleset(name="kafka") {
  :msg, !contains, "timestamp" ~
  action (
    type="omkafka"
    topic="nginx-accesslog"
    broker=["192.168.1.1:9092", "192.168.1.2:9092", "192.168.1.3:9092"]
    template="kafka_msg"
    confParam=["compression.codec=gzip"]
    partitions.auto="on"
  )
}

input(type="imudp" port="10514" Ruleset="kafka")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM