是否有任何API可显示对ES索引的写操作?

时间:2019-02-21 07:06:01

标签: elasticsearch monitoring

背景:-我有一个ES集群,该集群承载着许多客户索引,而且早在将近两年前,我们的应用程序就每月为每个客户创建一个新索引,而我们从未删除旧索引。

现在,由于磁盘空间问题,我们需要清理未使用的索引,但我们要再次确保未以任何方式使用旧索引。

我们使用了https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html,但是它不能提供可靠的证据证明该索引是否最近使用过。

听说过marvel,它可能有用,但看起来有些过头了,因为我们已经使用data dog来对我们的ES集群进行基本监视,并且已经有很多年了,我们没有紧迫的要求需要marvel

最好的解决方案是ES中的一些API,通过它们我们可以快速确定和删除旧索引。

1 个答案:

答案 0 :(得分:2)

您可以使用index stats API,它使您可以查看自上次重新启动以来给定索引是否已处理搜索或索引请求。

GET index/_stats
=>
  "_all": {
    "primaries": {
      "docs": {
        "count": 396885916,
        "deleted": 1712210
      },
      "store": {
        "size_in_bytes": 207383595268,
        "throttle_time_in_millis": 0
      },
      "indexing": {
        "index_total": 8,               <-- writes are happening if you see this increase
        "index_time_in_millis": 41,
        "index_current": 0,
        "index_failed": 0,
        "delete_total": 0,
        "delete_time_in_millis": 0,
        "delete_current": 0,
        "noop_update_total": 0,
        "is_throttled": false,
        "throttle_time_in_millis": 0
      },
      "get": {
        "total": 0,
        "time_in_millis": 0,
        "exists_total": 0,
        "exists_time_in_millis": 0,
        "missing_total": 0,
        "missing_time_in_millis": 0,
        "current": 0
      },
      "search": {
        "open_contexts": 7,
        "query_total": 30238,           <-- reads are happening if you see this increase
        "query_time_in_millis": 254000,
        "query_current": 0,
        "fetch_total": 816,
        "fetch_time_in_millis": 25997,
        "fetch_current": 0,
        "scroll_total": 7637,
        "scroll_time_in_millis": 686963111,
        "scroll_current": 7,
        "suggest_total": 0,
        "suggest_time_in_millis": 0,
        "suggest_current": 0
      },