1

我正在使用 ELK watcher 进行警报 2.2 版,我的查询输出是这样的

{
    "took": 549,
    "timed_out": false,
    "_shards": {
    "total": 1040,
    "successful": 1040,
    "failed": 0
},
"hits": {
"total": 468101,
"max_score": 0,
"hits": [ ]
 },
 "aggregations": {
   "2": {
     "buckets": [
     {
      "6": {
        "doc_count_error_upper_bound": 0,
        "sum_other_doc_count": 0,
          "buckets": [
             {
               "1": {
               "value": 84.86304909560724
               },
             "key": "hostname",
             "doc_count": 10000
      }


         ]
 },
    "key_as_string": "2016-11-09T19:00:00.000Z",
    "key": 1478718000000,
    "doc_count": 47855
}

在观察者的情况下,我想比较“值”是否大于某个阈值,

我尝试使用 array_compare 但它不适用于像这样的嵌套数组,它与字段匹配到 sum_other_doc_count 但不会更进一步。

如果有人可以帮助我

4

1 回答 1

0

这似乎与我试图弄清楚的事情相似。假设您只是比较数组/存储桶的第一个元素中的值没问题,我很幸运地使用了以下语法:

"condition": {
    "compare": {
        "ctx.payload.aggregations.2.buckets.0.6.buckets.1.value": {
            "gte": 80
        }
    }
}

我建议命名您的“aggs”以避免上面的“幻数”(除了存储桶中第一个元素的硬编码“0”)。

于 2017-01-20T20:09:43.627 回答