elasticsearch - ELK Logstash无法在ES中创建索引

标签 elasticsearch logstash filebeat

在遵循此tuto(https://www.bmc.com/blogs/elasticsearch-logs-beats-logstash/)以使用logstash分析某些日志文件之后,我的索引在第一次创建时就很好,然后我想用新的过滤器和新的存储库重新索引新文件,因此我通过“curl XDELETE”删除了”索引,现在当我重新启动logstash和filebeat时,不再创建索引。。启动组件时,我看不到任何错误。
是否需要删除其他内容才能重新创建索引?

最佳答案

好的,因为我的猜测(请参阅评论)是正确的,所以这里的解释是:

为避免filebeat反复读取和发布文件行,它使用注册表来存储收割机的当前状态:

The registry file stores the state and location information that Filebeat uses to track where it was last reading.



如您所述,filebeat成功收获了文件,将行发送到logstash,logstash将事件发布到了elasticsearch,后者创建了所需的索引。由于filebeat更新了其注册表,因此无需删除更多行,因此即使删除索引,也不会将事件再次发布到logstash。当您插入一些新行时,filebeat重新打开了收割机,并仅将新行(在“注册表检查点”之后)发布到logstash。

注册表文件的默认位置是${path.data}/registry(请参阅Filebeat's Directory Layout Overview)。

... maybe the curl api call is not the best solution to restart the index



这与删除索引无关。删除索引发生在elasticsearch内部。 Filebeat不了解您在Elasticsearch中的操作。

Q: Is there a way to re-create an index based on old logs?



是的,您应该考虑以下几种方法:
  • 您可以使用reindex API将文档从一个索引复制到另一个索引。您可以在将文档重新索引到新索引的同时更新文档。
  • 与重新索引相反,您可以使用update by query API更新将保留在原始索引中的文档。
  • 最后,您当然可以删除注册表文件。但是,这可能会导致数据丢失。但是出于开发目的,我想那很好。

  • 希望我能为您服务。

    关于elasticsearch - ELK Logstash无法在ES中创建索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59561751/

    相关文章:

    ruby-on-rails - Elasticsearch新手:与Rails和localhost:9200集成

    python - Pandas DataFrame上的NaN替换引发TypeError:找不到匹配的签名

    security - elasticsearch在正在运行的集群上应用安全性

    elasticsearch - 如何仅收集Filebeat中的错误级别日志并发送给elasticsearch

    elasticsearch - 需要在文档内部数组对象上聚合-ElasticSearch

    python - Elastic Search Function_Score Query with Query_String

    json - 从 JSON 中提取时间戳并将其用作 logstash 事件时间戳

    file - Logstash 不读取文件输入

    elasticsearch - 为什么Filebeat无法连接到Logstash

    使用 decode_json_fields 时出现 elasticsearch filebeat mapper_parsing_exception