我正在尝试根据我的时区调整返回的日期时间值。我的通知如下所示:
An abnormally low number of events occurred around 2016-09-28 22:49 CEST.
这是参考我的时区的正确日期。在通知的字段部分中,我有时间进入 UTC-0 区域:
@timestamp: 2016-09-28T20:49:44.711696Z
我曾尝试以这种方式使用增强功能,请提交..\elastalert\elastalert_modules
from datetime import datetime
from elastalert.enhancements import BaseEnhancement
class TimeEnhancement(BaseEnhancement):
def process(self, match):
if '@timestamp' in match:
now = datetime.now()
hours2 = datetime(0, 0, 0, 2, 0, 0)
match['@timestamp'] = now + hours2
我还在规则中添加了用法:
match_enhancements:
- "elastalert_modules.my_enhancements.TimeEnhancement"
只是为了测试,不是为了最终的解决方案