日志未通过 Fluentd 刷新到 Elasticsearch 容器
Logs not being flushed to Elasticsearch container through Fluentd
我有一个本地设置 运行宁 2 个容器 -
一个用于 Elasticsearch(开发设置详见此处 - https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html)。我 运行 按照文章中的指示使用 - docker run -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" docker.elastic.co/elasticsearch/elasticsearch:5.4.1
另一个作为 Fluentd 聚合器(使用此基本映像 - https://hub.docker.com/r/fluent/fluentd/)。我的 fluent.conf
用于测试目的如下:
<source>
@type forward
port 24224
</source>
<match **>
@type elasticsearch
host 172.17.0.2 # Verified internal IP address of the ES container
port 9200
user elastic
password changeme
index_name fluentd
buffer_type memory
flush_interval 60
retry_limit 17
retry_wait 1.0
include_tag_key true
tag_key docker.test
reconnect_on_error true
</match>
我从命令开始 - docker run -p 24224:24224 -v /data:/fluentd/log vg/fluentd:latest
当我 运行 我的进程(生成日志)和 运行 这两个容器时,我在 stdout
末尾看到 Fluentd 容器的以下内容 -
2017-06-15 12:16:33 +0000 [info]: Connection opened to Elasticsearch cluster => {:host=>"172.17.0.2", :port=>9200, :scheme=>"http", :user=>"elastic", :password=>"obfuscated"}
但是,除此之外,我没有看到任何日志。当我登录 http://localhost:9200
时,我只看到 Elasticsearch 欢迎消息。
我知道日志正在到达 Fluentd 容器,因为当我更改 fluent.conf
以重定向到文件时,我会按预期看到所有日志。我在设置 Elasticsearch 时做错了什么?我怎样才能在我的浏览器中/通过 Kibana 查看所有索引的正确布局?
看来你的方向是正确的。只需检查在 elasticsearch 中创建的索引,如下所示:
curl 'localhost:9200/_cat/indices?v'
文档:
https://www.elastic.co/guide/en/elasticsearch/reference/1.4/_list_all_indexes.html
在那里你可以看到每个索引名称。所以选择一个并在其中搜索:
curl 'localhost:9200/INDEXNAME/_search'
文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html
不过我还是推荐大家使用kibana,以获得更好的人机体验。只需启动它,默认情况下它会在本地主机中搜索弹性。在界面的配置中输入您现在知道的索引名称,然后开始使用它。
我有一个本地设置 运行宁 2 个容器 -
一个用于 Elasticsearch(开发设置详见此处 - https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html)。我 运行 按照文章中的指示使用 - docker run -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" docker.elastic.co/elasticsearch/elasticsearch:5.4.1
另一个作为 Fluentd 聚合器(使用此基本映像 - https://hub.docker.com/r/fluent/fluentd/)。我的 fluent.conf
用于测试目的如下:
<source>
@type forward
port 24224
</source>
<match **>
@type elasticsearch
host 172.17.0.2 # Verified internal IP address of the ES container
port 9200
user elastic
password changeme
index_name fluentd
buffer_type memory
flush_interval 60
retry_limit 17
retry_wait 1.0
include_tag_key true
tag_key docker.test
reconnect_on_error true
</match>
我从命令开始 - docker run -p 24224:24224 -v /data:/fluentd/log vg/fluentd:latest
当我 运行 我的进程(生成日志)和 运行 这两个容器时,我在 stdout
末尾看到 Fluentd 容器的以下内容 -
2017-06-15 12:16:33 +0000 [info]: Connection opened to Elasticsearch cluster => {:host=>"172.17.0.2", :port=>9200, :scheme=>"http", :user=>"elastic", :password=>"obfuscated"}
但是,除此之外,我没有看到任何日志。当我登录 http://localhost:9200
时,我只看到 Elasticsearch 欢迎消息。
我知道日志正在到达 Fluentd 容器,因为当我更改 fluent.conf
以重定向到文件时,我会按预期看到所有日志。我在设置 Elasticsearch 时做错了什么?我怎样才能在我的浏览器中/通过 Kibana 查看所有索引的正确布局?
看来你的方向是正确的。只需检查在 elasticsearch 中创建的索引,如下所示:
curl 'localhost:9200/_cat/indices?v'
文档: https://www.elastic.co/guide/en/elasticsearch/reference/1.4/_list_all_indexes.html
在那里你可以看到每个索引名称。所以选择一个并在其中搜索:
curl 'localhost:9200/INDEXNAME/_search'
文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html
不过我还是推荐大家使用kibana,以获得更好的人机体验。只需启动它,默认情况下它会在本地主机中搜索弹性。在界面的配置中输入您现在知道的索引名称,然后开始使用它。