【发布时间】:2014-04-24 08:17:32
【问题描述】:
- 我已经运行了logstash,并成功读取了一个文件
- rabbitmq正在运行,我在看日志,可以看到web界面
- 我已将 logstash 配置为输出到 rabbitmq 交换...我想!
问题出在:没有任何东西被发布到交易所,就像在网络界面中看到的那样。
有什么想法吗?
我的输出配置:
output {
rabbitmq {
codec => plain
host => localhost
exchange => yomtvraps
exchange_type => direct
}
file { path => "/tmp/heartbeat-from-logstash.log" }
}
更新:我正在看兔子日志
tail -F /usr/local/var/log/rabbitmq/rabbit\@localhost.log
事实证明,问题在于没有为交换和队列设置路由键。
一个工作配置是:
output {
rabbitmq {
codec => plain
host => localhost
exchange => yomtvraps
exchange_type => direct
key => yomtvraps
# these are defaults but you never know...
durable => true
port => 5672
user => "guest"
password => "guest"
}
}
这是一个示例接收器代码(使用 ruby "Bunny")
require "bunny"
conn = Bunny.new(:automatically_recover => false)
conn.start
ch = conn.create_channel
q = ch.queue("yomtvraps")
exchange = ch.direct("yomtvraps", :durable => true)
begin
puts " [*] Waiting for messages. To exit press CTRL+C"
q.bind(exchange, :routing_key => "yomtvraps").subscribe(:block => true) do |delivery_info, properties, body|
puts " [x] Received #{body}"
end
rescue Interrupt => _
conn.close
exit(0)
end
【问题讨论】:
-
问题似乎是我的交换从未发布到我的队列中,所以它毕竟不是真正的 logstash 问题