当es被安装在不同的端口上时,fluentd无法/显着地连接到elasticsearch

在我的docker环境中,弹性search(ES-1)暴露于端口9200,这是维护数据库数据的主要ES,所以为了logging日志,我们使用在端口9700上运行的新弹性search的fluentd-elasticsearch-kibna堆栈(ES-2)。

我无法连接fluentd到这个新的弹性search(ES-2)端口9700.让我知道如何连接fluentd以外的端口“9200”

下面是用于FEK的dockerconfiguration细节

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" 

下面是我使用上面的configuration时得到的错误信息

 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/ 

谢谢

你需要改变你的fluentdconfiguration如下

 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 。 这是因为我们应该关注容器端口而不是主机端口