如何对Elasticsearch中超过阈值的聚合求和?

时间:2019-10-07 23:46:16

标签: elasticsearch

我正在编写一个查询,以查找最近24小时内每15分钟间隔每个节点超过阈值的次数。我的查询当前提取时间间隔和时间范围的数据,但是我不知道如何对超过阈值的总值求和。有没有一种方法可以对每个cluster_node存储桶的值求和,以找到每个节点max_read超过X和max_write超过Y的总次数。

{
  "query":{
      "bool":{
          "filter":[{
              "range":{
                  "sampletime":{
                      "gte":"now-24h",
                      "format":"epoch_second"
                      }
                  }
              },{
              "query_string":{
                  "query" : "*:*"
              }
            }]
      }
  },
  "size": 0,
    "aggs": {
      "latency_over_time": {
        "date_histogram": {
          "field": "@timestamp",
          "interval": "15m"
        },
        "aggs":{
          "node":{
            "terms": {
              "_source": "instance_name",
              "size": 10000,
              "order":{
                "max_read": "desc",
                "max_write": "desc"
              },
              "min_doc_count": 1
            },
            "aggs":{
              "max_read": {
                "max":{
                  "field": "read_avg_latency"
                }
              },
              "max_write":{
                "max":{
                  "field": "write_avg_latency"
              }
            }
          }
        }
      }
    }
  }
}

0 个答案:

没有答案