elasticsearch - Fluentd似乎正在工作,但是在Kibana中没有日志

标签 elasticsearch kubernetes kibana fluentd

我有一个由两个容器组成的Kubernetes容器-主应用程序(将日志写入卷中的文件)和Fluentd sidecar,后者尾随日志文件并写入Elasticsearch。

这是Fluentd配置:

<source>
  type tail
  format none
  path /test/log/system.log
  pos_file /test/log/system.log.pos
  tag anm
</source>

<match **>
  @id elasticsearch
  @type elasticsearch
  @log_level debug
  time_key @timestamp
  include_timestamp true
  include_tag_key true
  host elasticsearch-logging.kube-system.svc.cluster.local
  port 9200
  logstash_format true
  <buffer>
    @type file
    path /var/log/fluentd-buffers/kubernetes.system.buffer
    flush_mode interval
    retry_type exponential_backoff
    flush_thread_count 2
    flush_interval 5s
    retry_forever
    retry_max_interval 30
    chunk_limit_size 2M
    queue_limit_length 8
    overflow_action block
  </buffer>
</match>

一切正常,Elasticsearch主机和端口正确,因为API可在该URL上正常工作。在Kibana中,我仅每5秒钟记录一次有关Fluentd创建新块的记录:
2018-12-03 12:15:50 +0000 [debug]: #0 [elasticsearch] Created new chunk chunk_id="57c1d1c105bcc60d2e2e671dfa5bef04" metadata=#<struct Fluent::Plugin::Buffer::Metadata timekey=nil, tag="anm", variables=nil>

但没有实际的Kibana日志(应用程序正在写入system.log文件的日志)。将Kibana配置为与唯一索引和唯一索引匹配的“logstash- *”索引模式。

Fluentd图片的版本:k8s.gcr.io/fluentd-elasticsearch:v2.0.4

Elasticsearch的版本:k8s.gcr.io/elasticsearch:v6.3.0

我在哪里可以检查出问题所在?看起来Fluentd无法将日志放入Elasticsearch,但是原因可能是什么?

最佳答案

答案很简单,可能会在将来对某人有所帮助。

我认为问题出在此源配置行:

<source>
...
    format none
...
</source>

这意味着在保存到elasticsearch时无需添加任何常规标签(例如pod或容器名称),我不得不以完全不同的方式在Kibana中搜索这些记录。例如,我使用自己的标签搜索这些记录,然后发现它们很好。自定义标签最初是为了以防万一而添加的,但事实证明它非常有用:
<source>
...
    tag anm
...
</source>

因此,最后的收获可能是以下内容。请谨慎使用“不格式化”,如果源数据实际上是非结构化的,则添加您自己的标签,并可能使用fluentd的record_transformer来添加其他标签/信息(例如“主机名”等),我最终也这样做了。这样,通过Kibana定位记录将更加容易。

关于elasticsearch - Fluentd似乎正在工作,但是在Kibana中没有日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53594419/

相关文章:

elasticsearch - 使用ElasticSearch Bulk动态更新和创建文档?

kubernetes - GKE : Modify existing cluster - remove node tags and change network

kubernetes - 从稳定的存储库自定义 Helm chart

elasticsearch - Kibana 连接到 ElasticSearch 的问题

php - 我如何使用php将Elasticsearch集成到mysql

elasticsearch - 如何使用 Kibana 创建具有平均值的时间线图表?

elasticsearch - 连字符上的打破字段值

elasticsearch - 如何删除与foreach处理器中的条件匹配的特定字段?

json - 如何解决空白分析器错误?

docker - Kubernetes 与 Mesos 上的 Kubernetes 对比?