问题描述
有没有一种方法可以将索引中的时间字段与当前时间进行比较。
我的索引如下:
"Timestamp":
"Status" : "mmm","XXXXXX" : {
"SyncTime" : "2020-07-06T04:23:33.000Z"
我想比较SyncTime是否大于过去24小时。 我尝试了以下两种方法:
方法1:使用百分比规则
type: percentage_match
index: index-*
description: ""
is_enabled: true
buffer_time:
minutes: 60
timestamp_field: Timestamp
doc_type: "doc"
query_key: "Status"
match_bucket_filter:
term:
XXXXXX.SyncTime > now-24h/d
max_percentage: 50
alert:
"email"
alert_subject: "XXXXXX"
alert_text: |
elastalert_error-{'message':“运行查询时出错:RequestError(400,u'parsing_exception',u'term查询格式错误
方法2:使用扁平线
index: index-*
type: flatline
doc_type: doc
is_enabled: true
description: ""
timeframe:
minutes: 60
realert:
minutes: 0
timestamp_field: Timestamp
doc_type: "doc"
threshold: 1
filter:
script:
script:
inline: (doc.containsKey('XXXXX.SyncTime') && doc['XXXXX.SyncTime'].value > now-24h/d)
threshold: 1
在这种情况下,匹配为零,匹配为1K +
elastalert_status-{'hits':0,'matches':1380,'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)