I'm trying to launch Logstash from a docker image to send logs to a RabbitMQ instance running on another docker container.
I linked both containers and launched Logstash with the following command and config file:
docker run --link rabbitmq:rabbit -it log-sender logstash -f config.conf
config.conf:
input {
stdin {
}
}
output {
rabbitmq {
host => "RABBIT_PORT_5672_TCP_ADDR"
exchange => "test_exchange"
exchange_type => "fanout"
}
}
I obtained the following error:
RabbitMQ connection error: Connection to RABBIT_PORT_5672_TCP_ADDR:5672 refused: host unknown. Will attempt to reconnect in 10 seconds... {:exception=>#, :backtrace=>["/opt/logstash/vendor/bundle/jruby/1.9/gems/march_hare- 2.1.2-java/lib/march_hare/session.rb:361:in 'converting_rjc_exceptions_to_ruby'" , "/opt/logstash/vendor/bundle/jruby/1.9/gems/march_hare-2.1.2-java/lib/march_ha re/session.rb:382:in 'new_connection_impl'", "/opt/logstash/vendor/bundle/jruby/ 1.9/gems/march_hare-2.1.2-java/lib/march_hare/session.rb:82:in 'initialize'", "/ ... uts/rabbitmq/march_hare.rb:18:in 'register'", "org/jruby/RubyArray.java:1613:in 'each'", "/opt/logstash/lib/logstash/pipeline.rb:220:in 'outputworker'", "/opt/l ogstash/lib/logstash/pipeline.rb:152:in `start_outputs'"], :level=>:error}
The rabbit docker is the base image, run with this command:
docker run -d -p 5672:5672 -p 15672:15672 rabbitmq
It seems that for some reason my Logstash image can't access to the port of the RabbitMQ image. Using curl I can get the response "AMPQ" when used from the host on port 5672, but not from the Logstash image.
RABBIT_PORT_5672_TCP_ADDR
reachable? Probably you have to specify conatiner hostname (-h
or--hostname
) and use it in your config, or if your logstash also reside inside container then simplelocalhost
will be fine. – pinepain