2017-09-14 45 views
0

我在Elasticsearch中创建了一个监视器,以便在60分钟内HTTP错误的比率大于总请求的15%时提醒我。 我正在使用链式输入来生成我的比率计算的除数和除数值。无法在Elasticsearch观察器中划分多个上下文值

在我的情况下,我正在使用脚本执行除法并检查它是否大于我的比例。

但是,无论何时我使用2个ctx参数进行除法,它总是等于零。

如果我玩它,只使用ctx参数之一,那么它工作正常。

看来我们不能在一个条件下使用2个ctx参数。

有谁知道如何解决这个问题?

以下是我的手表。

谢谢。

{ 
    "trigger" : { 
    "schedule" : { 
     "interval" : "5m" 
    } 
    }, 
    "input" : { 
    "chain":{ 
     "inputs": [ 
     { 
     "first": { 
      "search" : { 
      "request" : { 
       "indices" : [ "logstash-*" ], 
       "body" : { 
       "query" : { 
        "bool":{ 
        "must": [ 
         { 
         "match" : {"d.uri": "xxxxxxxx"} 
         }, 
         { 
         "match" : {"topic": "xxxxxxxx"} 
         } 
        ], 
        "filter": { 
         "range": { 
         "@timestamp": { 
          "gte": "now-60m" 
         } 
         } 
        } 
        } 
       } 
       } 
      }, 
      "extract": ["hits.total"] 
      } 
     } 
     }, 
     { 
     "second": { 
      "search" : { 
      "request" : { 
       "body" : { 
       "query" : { 
        "bool":{ 
        "must": [ 
         { 
         "match" : {"d.uri": "xxxxxxxx"} 
         }, 
         { 
         "match" : {"topic": "xxxxxxxx"} 
         }, 
         { 
         "match" : {"d.status": "401"} 
         } 
        ], 
        "filter": { 
         "range": { 
         "@timestamp": { 
          "gte": "now-60m" 
         } 
         } 
        } 
        } 
       } 
       } 
      }, 
      "extract": ["hits.total"] 
      } 
     } 
     } 
     ] 
    } 
    }, 
    "condition" : { 
    "script" : { 
     "source" : "return (ctx.payload.second.hits.total/ctx.payload.first.hits.total) == 0" 
    } 
    } 
} 

回答

0

这个问题实际上来自于我正在做一个整数除法以达到0.xx形式的比率。 我扭转了操作,它工作正常。

相关问题