fluentd не может/примечательно подключиться к elasticsearch, когда es установлен на другом порту

в моей среде докера есть эластичный поиск (ES-1), открытый для порта 9200, это основной ES для поддержки данных БД, поэтому для ведения журнала мы используем стек fluentd-elasticsearch-kibna с новым эластичным поиском, работающим на порту 9700. (ЭС-2) .

Я не могу подключить fluentd к этому новому эластичному поиску (ES-2) к порту 9700. Дайте мне знать, как подключить fluentd к es, отличному от порта «9200».

ниже приведены сведения о конфигурации докера, используемые для F-E-K.

 fluentd.config :
    <source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>

<match *.**>
  @type copy
  <store>
    @type elasticsearch
    host elasticsearchkibana
    port 9200
    logstash_format true
    logstash_prefix fluentd
    logstash_dateformat %Y%m%d
    include_tag_key true
    type_name access_log
    tag_key @log_name
    flush_interval 1s
  </store>
  <store>
    @type stdout
  </store>
</match>


docker-compose.yml :

   version: '2'
services:
  web:
    image: httpd
    ports:
      - "80:80"
    links:
      - fluentd
    logging:
      driver: "fluentd"
      options:
        fluentd-address: localhost:24224
        tag: httpd.access

  elasticsearchkibana:
    image: elasticsearch
    environment:
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    expose:
      - 9800
    ports:
      - "9700:9300"
      - "9800:9200"

  fluentd:
    build: ./fluentd
    volumes:
      - ./fluentd/conf:/fluentd/etc
    links:
      - "elasticsearchkibana"
    ports:
      - "24224:24224"
      - "24224:24224/udp"

  kibana:
    image: kibana
    environment:
      - ELASTICSEARCH_URL=http://elasticsearchkibana:9200
#      - "ES_HOST=192.168.241.82"
#      - "ES_PORT=9700"
    ports:
      - "5601:5601"

Ниже приведено СООБЩЕНИЕ ОБ ОШИБКЕ, которое я получаю, когда использую вышеуказанную конфигурацию.

fluentd_1              | 2017-09-25 15:16:36 +0000 fluent.warn: {"next_retry":"2017-09-25 15:16:37 +0000","error_class":"Fluent::ElasticsearchOutput::ConnectionFailure","error":"Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!","plugin_id":"object:2af57e68ced4","message":"temporarily failed to flush the buffer. next_retry=2017-09-25 15:16:37 +0000 error_class=\"Fluent::ElasticsearchOutput::ConnectionFailure\" error=\"Can not reach Elasticsearch cluster ({:host=>\\\"localhost\\\", :port=>9700, :scheme=>\\\"http\\\"})!\" plugin_id=\"object:2af57e68ced4\""}
fluentd_1              | 2017-09-25 15:16:37 +0000 [warn]: temporarily failed to flush the buffer. next_retry=2017-09-25 15:16:39 +0000 error_class="Fluent::ElasticsearchOutput::ConnectionFailure" error="Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!" plugin_id="object:2af57e68ced4"
fluentd_1              |   2017-09-25 15:16:37 +0000 [warn]: suppressed same stacktrace
fluentd_1              | 2017-09-25 15:16:37 +0000 fluent.warn: {"next_retry":"2017-09-25 15:16:39 +0000","error_class":"Fluent::ElasticsearchOutput::ConnectionFailure","error":"Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!","plugin_id":"object:2af57e68ced4","message":"temporarily failed to flush the buffer. next_retry=2017-09-25 15:16:39 +0000 error_class=\"Fluent::ElasticsearchOutput::ConnectionFailure\" error=\"Can not reach Elasticsearch cluster ({:host=>\\\"localhost\\\", :port=>9700, :scheme=>\\\"http\\\"})!\" plugin_id=\"object:2af57e68ced4\""}
fluentd_1              | 2017-09-25 15:16:39 +0000 [warn]: temporarily failed to flush the buffer. next_retry=2017-09-25 15:16:43 +0000 error_class="Fluent::ElasticsearchOutput::ConnectionFailure" error="Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!" plugin_id="object:2af57e68ced4"
fluentd_1              |   2017-09-25 15:16:39 +0000 [warn]: suppressed same stacktrace
fluentd_1              | 2017-09-25 15:16:39 +0000 fluent.warn: {"next_retry":"2017-09-25 15:16:43 +0000","error_class":"Fluent::ElasticsearchOutput::ConnectionFailure","error":"Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!","plugin_id":"object:2af57e68ced4","message":"temporarily failed to flush the buffer. next_retry=2017-09-25 15:16:43 +0000 error_class=\"Fluent::ElasticsearchOutput::ConnectionFailure\" error=\"Can not reach Elasticsearch cluster ({:host=>\\\"localhost\\\", :port=>9700, :scheme=>\\\"http\\\"})!\" plugin_id=\"object:2af57e68ced4\""}
fluentd_1              | 2017-09-25 15:16:43 +0000 [warn]: temporarily failed to flush the buffer. next_retry=2017-09-25 15:16:50 +0000 error_class="Fluent::ElasticsearchOutput::ConnectionFailure" error="Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!" plugin_id="object:2af57e68ced4"
fluentd_1              |   2017-09-25 15:16:43 +0000 [warn]: suppressed same stacktrace
fluentd_1              | 2017-09-25 15:16:43 +0000 fluent.warn: {"next_retry":"2017-09-25 15:16:50 +0000","error_class":"Fluent::ElasticsearchOutput::ConnectionFailure","error":"Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!","plugin_id":"object:2af57e68ced4","message":"temporarily failed to flush the buffer. next_retry=2017-09-25 15:16:50 +0000 error_class=\"Fluent::ElasticsearchOutput::ConnectionFailure\" error=\"Can not reach Elasticsearch cluster ({:host=>\\\"localhost\\\", :port=>9700, :scheme=>\\\"http\\\"})!\" plugin_id=\"object:2af57e68ced4\""}
fluentd_1              | 2017-09-25 15:16:50 +0000 [warn]: temporarily failed to flush the buffer. next_retry=2017-09-25 15:17:04 +0000 error_class="Fluent::ElasticsearchOutput::ConnectionFailure" error="Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!" plugin_id="object:2af57e68ced4"
fluentd_1              |   2017-09-25 15:16:50 +0000 [warn]: suppressed same stacktrace
fluentd_1              | 2017-09-25 15:16:50 +0000 fluent.warn: {"next_retry":"2017-09-25 15:17:04 +0000","error_class":"Fluent::ElasticsearchOutput::ConnectionFailure","error":"Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!","plugin_id":"object:2af57e68ced4","message":"temporarily failed to flush the buffer. next_retry=2017-09-25 15:17:04 +0000 error_class=\"Fluent::ElasticsearchOutput::ConnectionFailure\" error=\"Can not reach Elasticsearch cluster ({:host=>\\\"localhost\\\", :port=>9700, :scheme=>\\\"http\\\"})!\" plugin_id=\"object:2af57e68ced4\""}
fluentd_1              | 2017-09-25 15:17:04 +0000 [warn]: temporarily failed to flush the buffer. next_retry=2017-09-25 15:17:39 +0000 error_class="Fluent::ElasticsearchOutput::ConnectionFailure" error="Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!" plugin_id="object:2af57e68ced4"
fluentd_1              |   2017-09-25 15:17:04 +0000 [warn]: suppressed same stacktrace
fluentd_1              | 2017-09-25 15:17:04 +0000 fluent.warn: {"next_retry":"2017-09-25 15:17:39 +0000","error_class":"Fluent::ElasticsearchOutput::ConnectionFailure","error":"Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!","plugin_id":"object:2af57e68ced4","message":"temporarily failed to flush the buffer. next_retry=2017-09-25 15:17:39 +0000 error_class=\"Fluent::ElasticsearchOutput::ConnectionFailure\" error=\"Can not reach Elasticsearch cluster ({:host=>\\\"localhost\\\", :port=>9700, :scheme=>\\\"http\\\"})!\" plugin_id=\"object:2af57e68ced4\""}
fluentd_1              | 2017-09-25 15:17:39 +0000 [warn]: temporarily failed to flush the buffer. next_retry=2017-09-25 15:18:46 +0000 error_class="Fluent::ElasticsearchOutput::ConnectionFailure" error="Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!" plugin_id="object:2af57e68ced4"
fluentd_1              | 2017-09-25 15:17:39 +0000 fluent.warn: {"next_retry":"2017-09-25 15:18:46 +0000","error_class":"Fluent::ElasticsearchOutput::ConnectionFailure","error":"Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!","plugin_id":"object:2af57e68ced4","message":"temporarily failed to flush the buffer. next_retry=2017-09-25 15:18:46 +0000 error_class=\"Fluent::ElasticsearchOutput::ConnectionFailure\" error=\"Can not reach Elasticsearch cluster ({:host=>\\\"localhost\\\", :port=>9700, :scheme=>\\\"http\\\"})!\" plugin_id=\"object:2af57e68ced4\""}
fluentd_1              |   2017-09-25 15:17:39 +0000 [warn]: suppressed same stacktrace
fluentd_1              | 2017-09-25 15:18:46 +0000 [warn]: temporarily failed to flush the buffer. next_retry=2017-09-25 15:20:49 +0000 error_class="Fluent::ElasticsearchOutput::ConnectionFailure" error="Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!" plugin_id="object:2af57e68ced4"
fluentd_1              |   2017-09-25 15:18:46 +0000 [warn]: suppressed same stacktrace
fluentd_1              | 2017-09-25 15:18:46 +0000 fluent.warn: {"next_retry":"2017-09-25 15:20:49 +0000","error_class":"Fluent::ElasticsearchOutput::ConnectionFailure","error":"Can not reach Elasticsearch cluster ({:host=>\"localhost\", :port=>9700, :scheme=>\"http\"})!","plugin_id":"object:2af57e68ced4","message":"temporarily failed to flush the buffer. next_retry=2017-09-25 15:20:49 +0000 error_class=\"Fluent::ElasticsearchOutput::ConnectionFailure\" error=\"Can not reach Elasticsearch cluster ({:host=>\\\"localhost\\\", :port=>9700, :scheme=>\\\"http\\\"})!\" plugin_id=\"object:2af57e68ced4\""}
root@docker-test:/home/tlirlogin/docker-compose-efk-master2# cd fluentd/conf/

Спасибо


person k.explorer    schedule 25.09.2017    source источник
comment
Ваш fluentd работает внутри контейнерной сети, а не на хосте. Таким образом, порт по-прежнему должен быть 9200, даже если вы сопоставляете 9700 на хосте. Поскольку в этом случае соединение зависит от порта контейнера   -  person Tarun Lalwani    schedule 25.09.2017
comment
@tarun Laiwani все еще получает сообщение об ошибке при изменении fluentd_1 fluent.warn: error_class:Fluent::ElasticsearchOutput::ConnectionFailure,error:Не удается получить доступ к кластеру Elasticsearch ({:host=›\elasticsearchkibana\, :port=›9200, :scheme=› \http\})!,plugin_id:object:2ac5be462aa4,message:временно не удалось очистить буфер. next_retry=2017-09-26 05:14:24 +0000 error_class=\Fluent::ElasticsearchOutput::ConnectionFailure\ error=\Не удается получить доступ к кластеру Elasticsearch   -  person k.explorer    schedule 26.09.2017
comment
Можете ли вы поделиться файлом докера fluentd? Так что я могу попробовать создать ваш файл.   -  person Tarun Lalwani    schedule 26.09.2017
comment
@TarunLalwani Привет, я отредактировал вопрос с новой конфигурацией, пожалуйста, найдите .. Спасибо.   -  person k.explorer    schedule 26.09.2017
comment
Я не ищу конфигурацию, мне нужен Dockerfile, который вы использовали для сборки fluentd.   -  person Tarun Lalwani    schedule 26.09.2017
comment
Найдите файл докеров: FROM fluent/fluentd:v0.12 RUN [gem, install, fluent-plugin-elasticsearch, --no-rdoc, --no-ri, --version, 1.9.5]   -  person k.explorer    schedule 26.09.2017
comment
Нет проблем, вы увидите это сообщение в течение нескольких секунд, потому что когда-нибудь ES встанет, после этого вы не увидите проблемы с подключением. Я проверил локально, и он работает через несколько секунд   -  person Tarun Lalwani    schedule 26.09.2017
comment
Спасибо!!! это очень помогло, теперь я могу вести журналы из всех контейнеров и хранить в Es, просто нужно проверить интерфейс kibana..   -  person k.explorer    schedule 26.09.2017


Ответы (1)


Вам нужно изменить конфигурацию Fluent, как показано ниже.

fluentd.config :
<source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>

<match *.**>
  @type copy
  <store>
    @type elasticsearch
    host elasticsearchkibana
    port 9200
    logstash_format true
    logstash_prefix fluentd
    logstash_dateformat %Y%m%d
    include_tag_key true
    type_name access_log
    tag_key @log_name
    flush_interval 1s
  </store>
  <store>
    @type stdout
  </store>
</match>

Так что в основном добавьте host elasticsearchkibana и измените на port 9200. Это потому, что мы должны беспокоиться о порте контейнера, а не о порте хоста.

person Tarun Lalwani    schedule 25.09.2017