Logstash docker image doesn't connect to elasticsearch image

Hi,
I'm a new user of Elasticsearch / Kibana / Logstash with docker images.
I launched the images using the following commands:

docker run -d -p 9200:9200 -p 9300:9300 --network=elastic -it --rm --name elasticsearch -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch-oss:6.1.1

docker run -d  -p 5601:5601 --network=elastic -it --rm --name kibana --link elasticsearch:elasticsearch docker.elastic.co/kibana/kibana-oss:6.1.1

docker run --network=elastic --name logstash --link elasticsearch:elasticsearch -it --rm -v ~/Desktop/ELK/pipeline:/config-dir -v ~/Desktop/ELK/data/:/usr/share/logstash/data/ docker.elastic.co/logstash/logstash-oss:6.1.1 -f /config-dir/conf_test.conf

My conf_test.conf file is a very simple one, it is the following:

input { stdin{} }
output { 
	elasticsearch {  hosts => ["localhost:9200"] }
	stdout { codec => rubydebug }
}

The elasticsearch docker image is running, and I get an answer when I go to localhost:9200/

When I launch the logstash docker image, I always get this error message:

[2018-01-01T11:48:02,105][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>http://localhost:9200/, :path=>"/"}
[2018-01-01T11:48:02,113][WARN ][logstash.outputs.elasticsearch] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://localhost:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://localhost:9200/][Manticore::SocketException] Connection refused (Connection refused)"}

When I enter things with the keyboard, I get the following message:

[2018-01-01T11:48:02,025][FATAL][logstash.runner          ] An unexpected error occurred! {:error=>#<NoMethodError: undefined method `<' for nil:NilClass>, :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-elasticsearch-9.0.2-java/lib/logstash/outputs/elasticsearch/common.rb:213:in `get_event_type'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-elasticsearch-9.0.2-java/lib/logstash/outputs/elasticsearch/common.rb:165:in `event_action_params'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-elasticsearch-9.0.2-java/lib/logstash/outputs/elasticsearch/common.rb:39:in `event_action_tuple'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-elasticsearch-9.0.2-java/lib/logstash/outputs/elasticsearch/common.rb:34:in `block in multi_receive'", "org/jruby/RubyArray.java:2486:in `map'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-elasticsearch-9.0.2-java/lib/logstash/outputs/elasticsearch/common.rb:34:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/output_delegator_strategies/shared.rb:13:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/output_delegator.rb:50:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:487:in `block in output_batch'", "org/jruby/RubyHash.java:1343:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:486:in `output_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:438:in `worker_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:393:in `block in start_workers'"]}

Any idea on what should be done?
Many thanks

Don't use localhost as the hostname, use elasticsearch.

1 Like

It works perfectly well now!
Thank you very much for your help!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.