Question

  • I've got logstash running, and successfully reading in a file
    • rabbitmq is running, I'm watching the log, and I can see the web interface
    • I've configured logstash to output to a rabbitmq exchange... I think!

Here's the problem: nothing ever gets posted to the exchange, as seen in the web interface.

Any ideas?

My output config:

output {
            rabbitmq {
                    codec => plain
                    host => localhost
                    exchange => yomtvraps
                    exchange_type => direct
            }

        file { path => "/tmp/heartbeat-from-logstash.log" }
}

UPDATE: I'm watching the rabbit log with tail -F /usr/local/var/log/rabbitmq/rabbit\@localhost.log

As it turns out, the problem was that there was no routing key set for the exchange and queue.

A working config is:

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"
   }
}

Here's a sample receiver code (using 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
Was it helpful?

Solution

  1. you rabbitmq's parameter seems not enough, username,password and port have not been configured.

  2. You can configure two outputs, one is to rabbitmq, the other is to file for vertifying the log's creation and log stash is ok.

  3. pay attention to the logstash's version(log stash, rabbitmq plugin), it gave me lots of trouble in my trial before (log stash to another redis server etc).

  4. You could debug rabbitmq's log.

ps -ef|grep erl you could find the log file's path in the arguments.

  1. Be sure that rabbitmq's web manager plugin is enabled, and firewall is rightly configured, then open rabbitmq's web manager, ipaddress:15672

  2. check the exchange's type is ok (in this case 'direct' may be a correct choice), your message consumer is configured ok, and your consumer's queue has been been bound to the exchange correctly.

  3. try to post the message to your consumer through web manager and ensure consumer work well.

  4. Monitor your queue when log stash push log into your consumer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top