Logstash docker container can not connect to the ElasticSearch (non-docker) on another host

Hi

I have 2 docker containers: filebeat and logstash which I run using docker-compose. I am trying to configure logstash such that it will write index to the Elasticsearch (non-docker) hosted on another node.

Here is my docker-compose file:

version: '3.5'

services:
  logstash:
    container_name: logstash
    build:
      context: logstash/
    restart: always
    environment: 
      LS_JAVA_OPTS: "-Xmx256m -Xms256m"
    ports:
    - 5044:5044
    - 9600:9600
    - 9200:9200

My logstash pipeline has following code in order to connect to the Elasticsearch:

output {
  elasticsearch {
    hosts => ["http://myelasticnode:9200"]
    user => "elastic"
    password => "elastic"
    index => "%{[%metadata][beat]}-%{+YYYY.MM.dd}"
    document_type => "%{[@metadata][type]}"
  }
}

I get an error: Attempted to resurrect connection to dead ES instance, but got an error. {url=>http://elastic:elastic@myelasticnode:9200/", error_type=>Logstash::Outputs::Elasticsearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable. myelasticnode: Name or service not known"}

On the host where logstash docker container is running, I can curl to the elasticsearch node which gives a valid json output message. What do I need to do so that logstash docker container can communicate with Elasticsearch (not a docker container)?

Thanks in advance.
Ram

1 Like

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