【问题标题】:How to delete all old indices without elasticsearch-curator?如何在没有 elasticsearch-curator 的情况下删除所有旧索引?
【发布时间】:2019-06-05 07:34:24
【问题描述】:

我想在不使用 curator 的情况下从 elasticsearch 中删除旧的(比如说过去 10 天)索引。有没有其他方法可以删除所有旧索引? (有没有办法使用 Node.js 删除索引)

注意:我用谷歌搜索过,但没有找到任何合适的答案,而且很多人都在使用 curator。

【问题讨论】:

  • 你的索引的命名模式是什么?
  • @Val 我的索引模式是“tenentidentifier_appidentifier_instanceidentifier_@timestamp”
  • 您可以创建自己的脚本(甚至在 Bash 中)来删除您的旧索引。

标签: node.js elasticsearch elasticsearch-5


【解决方案1】:

为什么不直接使用删除索引 API? https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html

为了找到最旧的索引,如果索引名称或翻转没有命名约定,您可以检查每个索引中的最小和最大时间戳是多少,然后根据该索引决定哪些索引删除。可以在此处找到从索引中获取这些时间戳的简单查询:What's the fastest manner to retrieve min timestamp from Elasticsearch indices?

【讨论】:

  • 感谢您的评论。如果我们使用“删除索引 API”,我们必须手动删除日志。 curator 所做的是,它会按照预定的时间删除所有的旧日志。我们可以通过提及时间和日期来自动删除日志。所以,它为我们删除。这就是我要找的。​​span>
  • 好吧,我还是不明白为什么你不能使用 curator,因为它就是这样做的。您将需要通过 cron 或任何其他调度程序运行 Curator,就像您将运行直接使用删除 API 的脚本一样,脚本在 cron 中调度。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-14
  • 2018-07-05
相关资源
最近更新 更多