日志未通过 Fluentd 刷新到 Elasticsearch 容器



我有一个运行 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

当我运行我的进程(生成日志)并运行这两个容器时,我在 Fluentd 容器的stdout末尾看到以下内容 -

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 以获得更好的人类体验。只需启动它,默认情况下它会在本地主机中搜索弹性。在界面的配置中输入您现在知道的索引名称,然后开始使用它。

最新更新