移动聚合 ElasticSearch

Moving Aggregations ElasticSearch

你好,我一直在努力为我的应用程序获取移动聚合和运行。

下面是我的文档的指标示例。

"_index" : "metrics-2017-06-23",
"_type" : "metric",
 "_id" : "AVzUTWSCHd9DG10LCpmo",
"_score" : 0.0,
    "_source" : {
  "organisation" : "Organisation",
  "deployments" : [
    {
      "deployment_name" : "tqwerty",
      "instances" : [
        {
          "instance_name" : "7962c130ae1247229ee67aa534172f77",
          "object" : "fff",
          "version" : "adacb76ebd21",
          "cpu" : [
            {
              "time" : 1498174600,
              "value" : 10000
            }
          ],
          "disk_read" : [
            {
              "time" : 1498174600,
              "value" : 430
            }
          ],
          "disk_write" : [
            {
              "time" : 1498174600,
              "value" : 0
            }
          ],
          "net_read" : [
            {
              "time" : 1498174600,
              "value" : 0
            }
          ],
          "net_write" : [
            {
              "time" : 1498174600,
              "value" : 0
            }
          ]
        }
      ]
    }
  ]
}
}
]

我已经将 Curl 请求放到它工作的地方,并隔离了我想要的部署。但它只是没有显示我移动的 agg。我不确定为什么要逐字逐句地阅读文档。

curl -XPOST '10.0.0.34:9200/_search?pretty' -H 'Content-Type: application/json' -d'
{
"size": 20,
"query": { 
  "bool": { 
   "must": [
  { "match": { "organisation":   "Organisation"        }},
 { "match":  { "deployments.deployment_name": "tqwerty" }}
   ]
}
},
    "aggs": {
    "my_date_histo":{                
    "date_histogram":{
        "field":"deployments.instances.cpu.time",
        "interval":"30s"
       },
        "aggs":{
            "the_sum":{
            "sum":{ "field": "deployments.instances.cpu.value" } 
            },
            "the_movavg":{
            "moving_avg":{ "buckets_path": "the_sum" } 
        }
    }
}
}
}
 '

Curl 请求运行正常但不显示移动聚合确实显示总和并且它与数据匹配良好。

谢谢,

这似乎解决了我的问题。这令人惊讶,因为前几天没有...如果其他人遇到此问题,请尝试 Tom 所说的,希望它对您有用。

这是我在评论中所说的-

 curl -XPOST 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'
     {
       "size": 0,
       "query": { 
              "bool": { 
                   "must": [
                         { "match": { "organisation":   "Organisation"}},
                         { "match":  { "deployments.deployment_name": "tqwerty" }}
                   ]
                  }
               },
       "aggs": {
                "my_date_histo":{                
                   "date_histogram":{
                      "field":"deployments.instances.cpu.time",
                      "interval":"30s"
              },
                 "aggs":{
                 "the_sum":{
                 "sum":{ "field": "deployments.instances.cpu.value" } 
                },
                 "the_movavg":{
                      "moving_avg":{ "buckets_path": "the_sum" } 
              }
          }
      }
   }
}

结论:将大小更改为 0