使用flatline框架创建ElastAlert警报类型。
当我以完全相同的语法在Kibana中使用查询时,它会返回结果,但是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似乎对语法没有问题。
有什么想法吗?
发布于 2018-01-12 19:28:04
我让it...just忘了发回信。
显然,对于带有空格的字段,您需要转义反斜杠,因此所讨论的行如下所示:
query: "_type:metric AND _exists_:My\\ Field\\ With\\ Spaces.value"此外,在使用Ansible (YAML)配置的特殊情况下,需要添加反斜杠来转义每个反斜杠。
因此,YAML文件中的条目如下所示:
query: "My\\\\ field\\\\ With\\\\ Spaces.value"发布于 2019-10-23 12:04:45
可以通过对字段数据使用双引号来避免转义:
query: '_type:metric AND _exists_:"My Field With Spaces.value"'https://stackoverflow.com/questions/46840033
复制相似问题