2017-10-19 147 views
1

使用ElastAlert框架創建一個flatline警報類型。ElastAlert flatline找不到結果

當我用完全相同的語法在Kibana UI中使用查詢時,它返回結果,但ElastAlert沒有返回任何結果。

這裏是我的elastalert規則-file.xml

name: Test Flatline 
type: flatline 
run_every: 
    seconds: 15 
relalert: 
    minutes: 0 
es_host: localhost 
es_port: 9200 
threshold: 1 
timeframe: 
    minutes: 5 
index: my-index-* 
filter: 
- query: 
    query_string: 
     query: "_type:metric" # this returns results in both kibana and elastalert 
     #query: "_type:metric AND _exists_:My\ Field\ With\ Spaces.value" # this returns results in kibana but not in elastalert 

timestamp_type: unix_ms 
alert: 
    - command 
command: ["my-bash-script.sh"] 

於是,我就玩的查詢,如果我只需指定_type:metric然後在Kibana搜索結果似乎以匹配ElastAlert。

但是,當我嘗試在第二個查詢中使用帶有_exists_ lucene語法的查詢時,ElastAlert不會返回任何內容,而Kibana似乎對語法沒有問題。

任何想法?

回答

0

我明白了......只是忘了發表一個答案。

顯然爲現場與大家需要逃避反斜槓所以在這個行應該是這樣的空間:

query: "_type:metric AND _exists_:My\\ Field\\ With\\ Spaces.value" 

此外,在特殊情況下使用的是你需要Ansible(YAML)配置添加反斜槓以轉義每個反斜槓。

所以在YAML文件中的條目將是這個樣子:

query: "My\\\\ field\\\\ With\\\\ Spaces.value"