Skip to content
This repository has been archived by the owner on Jun 22, 2020. It is now read-only.

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

Closed
kkgace opened this issue May 25, 2017 · 8 comments

Comments

@kkgace
Copy link

kkgace commented May 25, 2017

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'这个方法,这个需要如何解决,是什么原因引起的呢,谢谢

@anjia0532
Copy link
Owner

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

@anjia0532
Copy link
Owner

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

@minminmsn
Copy link

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

@anjia0532
Copy link
Owner

@minminmsn 感谢分享。

@anjia0532
Copy link
Owner

anjia0532 commented Jul 6, 2017

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

INFO:elastalert:Rule xxx disabled

@anjia0532
Copy link
Owner

anjia0532 commented Jul 24, 2017

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

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

@minminmsn
Copy link

@anjia0532 收到。

@kkgace
Copy link
Author

kkgace commented Aug 1, 2017

@anjia0532 非常感谢,已解决

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants