anjia0532/elastalert-wechat-plugin

Uncaught exception running rule test: global name 'EAException' is not defined

kkgace opened this issue · 8 comments

hello,我在使用这个python脚本的时候,遇到一个这样的问题:
报警是可以发送成功的,当报警一段时间后会出现一次这样的错误,然后报警规则被静默不再处理,错误信息如下:
Traceback (most recent call last):, File "/usr/local/elastalert/elastalert/elastalert.py", line 1169, in alert, return self.send_alert(matches, rule, alert_time=alert_time), File "/usr/local/elastalert/elastalert/elastalert.py", line 1246, in send_alert, alert.alert(matches), File "elastalert_modules/wechat_qiye_alert.py", line 49, in alert, self.senddata(body), File "elastalert_modules/wechat_qiye_alert.py", line 114, in senddata, raise EAException("send message has error: %s" % e), NameError: global name 'EAException' is not defined
我看了下确实没有'EAException'这个方法,这个需要如何解决,是什么原因引起的呢,谢谢

这是 elastalert 的错误,具体可以参考 官方项目 这是 EAException相关issues https://github.com/Yelp/elastalert/search?q=EAException&type=Issues&utf8=%E2%9C%93

具体你可以尝试根据你clone 的elastalert的源码,根据错误堆栈提示的信息,排查代码。因为不清楚你的版本和官网的版本是否一致,所以不太好根据你错误信息给出的行号排查

同样的问题,导入这个就可以了,0.1.14版本测试通过,from elastalert.util import EAException,备注下,如遇到这个问题可以参考下。

@minminmsn 感谢分享。

如果报异常后,会在控制台输出 该规则被禁用,此时除非重启,否则该规则就会被禁用。需要增加异常捕获。防止被禁用

INFO:elastalert:Rule xxx disabled

@minminmsn @kkgace 终极解决方案,使用 disable_rules_on_error
文档 http://elastalert.readthedocs.io/en/latest/elastalert.html?highlight=disable_rules_on_error

如果有未捕获的异常,需要通知的话,再加上 notify_email 将发送邮件

@anjia0532 收到。

@anjia0532 非常感谢,已解决