简体   繁体   English

Logstash插件输出到Kafka无效

[英]Logstash plugin to output to Kafka not working

I'm trying to send messages from Logstash to Kafka and keep getting the following error: 我正在尝试从Logstash向Kafka发送消息,并不断出现以下错误:

tail -f /var/log/logstash/logstash-plain.log
[2018-04-18T17:55:33,836][WARN ][org.apache.kafka.clients.NetworkClient] 
[Producer clientId=producer-1] Connection to node -1 could not be established. Broker may not be available.
[2018-04-18T17:55:46,095][INFO ][logstash.outputs.kafka   ] Sending batch to Kafka failed. Will retry after a delay. {:batch_size=>1, :failures=>1, :sleep=>0.1}
[2018-04-18T17:55:51,979][INFO ][logstash.outputs.kafka   ] Sending batch to Kafka failed. Will retry after a delay. {:batch_size=>1, :failures=>1, :sleep=>0.1}
[2018-04-18T17:56:46,196][INFO ][logstash.outputs.kafka   ] Sending batch to Kafka failed. Will retry after a delay. {:batch_size=>1, :failures=>1, :sleep=>0.1}]

This was working previously, but not now and I'm not sure what changed since the machine was untouched. 以前可以正常运行,但现在不行,而且我不确定由于未触摸机器而发生了什么变化。

I can communicate to Kafka through the console producer on the machine Kafka is running on, as well as the machine Logstash is running on, and from a remote machine out of the VPC, so I don't believe this is a network error. 我可以通过运行Kafka的计算机,运行Logstash的计算机以及从VPC以外的远程计算机上的控制台生产者与Kafka进行通信,所以我不认为这是网络错误。 To be sure, I put Logstash on the same machine as Kafka, but I get the same error. 可以肯定的是,我将Logstash与Kafka放在同一台机器上,但是遇到了同样的错误。

I double checked and made sure that I'm at the latest version of Kafka, Logstash, and the logstash-output-kafka plugin, so I don't think it's a compatibility issue either. 我仔细检查并确保我使用的是最新版本的Kafka,Logstash和logstash-output-kafka插件,因此我也不认为这是兼容性问题。 I have tried restarting Logstash and the broker to no avail. 我尝试重新启动Logstash和代理无济于事。

Basically, I'm at a loss at how to solve this issue. 基本上,我不知道如何解决此问题。 Any help would be appreciated. 任何帮助,将不胜感激。 Thanks. 谢谢。

Alright, I figured it out. 好吧,我知道了。 It was a configuration issue in the logstash.conf file: When I changed the kafka output to the machine's local IP address, it works. 这是logstash.conf文件中的一个配置问题:当我将kafka输出更改为机器的本地IP地址时,它可以工作。 It doesn't work with the public or private hostname, or the public IP address, it seems. 看来,它不能与公用或专用主机名或公用IP地址一起使用。 Since I am using a conditional with multiple kafka topics like so: 由于我正在使用带有多个kafka主题的条件,如下所示:

output {
  kafka {
    bootstrap_servers => "10.0.0.XX:9092"
    codec => json
    topic_id => "test_topic"
  }
  if [type] == "ping" {
    kafka {
      bootstrap_servers => "10.0.0.XX:9092"
      codec => json
      topic_id => "logstash-ping"
    }
  }
  else if [type] == "snmp" {
    kafka {
      bootstrap_servers => "10.0.0.XX:9092"
      codec => json
      topic_id => "logstash-snmp"
    }
  }
}

it won't send to any of them if any one of them is not set right, despite connecting correctly from what I could see in the logstash logs. 即使从logstash日志中看到的连接正确,即使其中任何一个设置不正确,它也不会发送给其中任何一个。

For reference, my settings for listeners and advertised.listeners are like so: 作为参考,我对监听器和advertised.listeners的设置如下:

listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://ec2-XX-XX-XX-XX.compute-1.amazonaws.com:9092

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

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