-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python3.6 企业微信无法报警,python2都快不支持了 #7
Comments
InsecureRequestWarning, |
我安装的Elastalert 用的python3.6 |
@yezhiyuan 目前你先别用python3,可能有函数以及类的不兼容,后期我会尽快过渡到python3. |
但现在安装的elastlaert python2默认不行,估计要安装你之前的分支才行;
…------------------ 原始邮件 ------------------
发件人: "Hello-Linux"<[email protected]>;
发送时间: 2019年11月6日(星期三) 晚上7:59
收件人: "Hello-Linux/elastalert_wechat_plugin"<[email protected]>;
抄送: "叶志远"<[email protected]>;"Author"<[email protected]>;
主题: Re: [Hello-Linux/elastalert_wechat_plugin] python3.6 企业微信无法报警,python2都快不支持了 (#7)
目前你别别用python3,可能有函数以及类的不兼容,后期我会尽快过渡到python3.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
启动后的日志你观察了么,有没有触发你的规则?再就是python2.7目前没有问题我自己的网站目前一直在使用中。 |
启动后一段时间会报这个错误;
InsecureRequestWarning,
ERROR:root:Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/elastalert/elastalert.py", line 1440, in alert
return self.send_alert(matches, rule, alert_time=alert_time, retried=retried)
File "/usr/local/lib/python3.6/dist-packages/elastalert/elastalert.py", line 1529, in send_alert
alert.alert(matches)
File "/root/elastalert/elastalert_wechat_plugin/es_rules/elastalert_modules/wechat_qiye_alert.py", line 63, in alert
self.senddata(body)
File "/root/elastalert/elastalert_wechat_plugin/es_rules/elastalert_modules/wechat_qiye_alert.py", line 130, in senddata
response = requests.post(send_url, data=json.dumps(payload, ensure_ascii=False), headers=headers,verify=False)
File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
**kw).encode(obj)
File "/usr/lib/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.6/json/encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'bytes' is not JSON serializable
然后等一会就会禁用我的报警规则了,有时候启动过很久才出现上面的错误,但是收不到告警,
应该语法哪里有问题吧,毕竟我是用python3跑的
我安装的Elastalert 用的pip3;默认python环境3.6,
…------------------ 原始邮件 ------------------
发件人: "Hello-Linux"<[email protected]>;
发送时间: 2019年11月6日(星期三) 晚上8:07
收件人: "Hello-Linux/elastalert_wechat_plugin"<[email protected]>;
抄送: "叶志远"<[email protected]>;"Mention"<[email protected]>;
主题: Re: [Hello-Linux/elastalert_wechat_plugin] python3.6 企业微信无法报警,python2都快不支持了 (#7)
启动后的日志你观察了么,有没有触发你的规则?再就是python2.7目前没有问题我自己的网站目前一直在使用中。
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
规则肯定触发了,到alert sent 一直都是0,我用邮件是正常的收到告警
…------------------ 原始邮件 ------------------
发件人: "Hello-Linux"<[email protected]>;
发送时间: 2019年11月6日(星期三) 晚上8:07
收件人: "Hello-Linux/elastalert_wechat_plugin"<[email protected]>;
抄送: "叶志远"<[email protected]>;"Mention"<[email protected]>;
主题: Re: [Hello-Linux/elastalert_wechat_plugin] python3.6 企业微信无法报警,python2都快不支持了 (#7)
启动后的日志你观察了么,有没有触发你的规则?再就是python2.7目前没有问题我自己的网站目前一直在使用中。
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
好的,谢谢你的反馈,目前我使用的elastlaert 是之前的旧版本我在测试环境试试最新版的,后面我观察一下。 |
@yezhiyuan 刚测试完了,是可以发送的,你这边检测一下你的微信配置有没有问题。 |
嗯;我的老是报这个错误,启动的时候
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 59.999921 seconds
INFO:elastalert:Queried rule es_rule from 2019-11-06 19:48 CST to 2019-11-06 20:03 CST: 85 / 85 hits
INFO:elastalert:Queried rule es_rule from 2019-11-06 20:03 CST to 2019-11-06 20:18 CST: 148 / 148 hits
INFO:elastalert:Queried rule es_rule from 2019-11-06 20:18 CST to 2019-11-06 20:33 CST: 116 / 116 hits
INFO:elastalert:Queried rule es_rule from 2019-11-06 20:33 CST to 2019-11-06 20:48 CST: 159 / 159 hits
INFO:elastalert:Queried rule es_rule from 2019-11-06 20:48 CST to 2019-11-06 21:03 CST: 135 / 135 hits
INFO:elastalert:Queried rule es_rule from 2019-11-06 21:03 CST to 2019-11-06 21:18 CST: 406 / 406 hits
INFO:elastalert:Queried rule es_rule from 2019-11-06 21:18 CST to 2019-11-06 21:33 CST: 483 / 483 hits
INFO:elastalert:Queried rule es_rule from 2019-11-06 21:33 CST to 2019-11-06 21:47 CST: 103 / 103 hits
/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py:1004: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning,
ERROR:root:Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/elastalert/elastalert.py", line 1440, in alert
return self.send_alert(matches, rule, alert_time=alert_time, retried=retried)
File "/usr/local/lib/python3.6/dist-packages/elastalert/elastalert.py", line 1529, in send_alert
alert.alert(matches)
File "/root/elastalert/elastalert_wechat_plugin/es_rules/elastalert_modules/wechat_qiye_alert.py", line 63, in alert
self.senddata(body)
File "/root/elastalert/elastalert_wechat_plugin/es_rules/elastalert_modules/wechat_qiye_alert.py", line 130, in senddata
response = requests.post(send_url, data=json.dumps(payload, ensure_ascii=False), headers=headers,verify=False)
File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
**kw).encode(obj)
File "/usr/lib/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.6/json/encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'bytes' is not JSON serializable
ERROR:root:Uncaught exception running rule es_rule: Object of type 'bytes' is not JSON serializable
测试语法好像没什么问题;
root@elk:~/elastalert/elastalert_wechat_plugin/es_rules# elastalert-test-rule --config config.yaml wechart.yaml
INFO:elastalert:Note: In debug mode, alerts will be logged to console but NOT actually sent.
To send them but remain verbose, use --verbose instead.
Didn't get any results.
INFO:elastalert:Note: In debug mode, alerts will be logged to console but NOT actually sent.
To send them but remain verbose, use --verbose instead.
1 rules loaded
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
INFO:elastalert:Queried rule es_rule from 2019-11-06 21:48 CST to 2019-11-06 21:49 CST: 1 / 1 hits
Would have written the following documents to writeback index (default is elastalert_status):
elastalert_status - {'rule_name': 'es_rule', 'endtime': datetime.datetime(2019, 11, 6, 13, 49, 29, 952623, tzinfo=tzutc()), 'starttime': datetime.datetime(2019, 11, 6, 13, 48, 29, 352623, tzinfo=tzutc()), 'matches': 0, 'hits': 1, '@timestamp': datetime.datetime(2019, 11, 6, 13, 49, 30, 41775, tzinfo=tzutc()), 'time_taken': 0.019246578216552734}
|
希望有空了帮忙看看上面的报错,应该就是那个问题导致无法报警 |
这个报错是python3.6的,你使用python2.7有问题么 |
root@elk:~/elastalert/elastalert_wechat_plugin/es_rules# elastalert-test-rule --config config.yaml wechart.yaml |
用python3.6语法测试没问题 |
root@elk:~/elastalert/elastalert_wechat_plugin/es_rules# python -m elastalert.elastalert --verbose --rule wechart.yaml Traceback (most recent call last): |
用python2.7安装的时候已经报错了; elastalert 0.2.1 is already the active version in easy-install.pth requests和requests-dev里面的依赖都正常安装了; |
应该是要python3才能安装上; |
默认安装的版本是0.2.1,然后你的手册要求必须python3; Requirements |
我现在的主要问题就是使用2.7安装报警器直接报错,用3.6可以装上,但是你的微信报警是用python2.7开发的,导致很多不兼容;多次打扰,真的是不好意思; |
@yezhiyuan 嗯嗯 后面我更新一下代码版本 |
好的,非常感谢! |
@yezhiyuan 最近在忙其他事情,我尽快吧。 |
谢谢你哈!辛苦了!你有空了就弄一下,没空就先放着!真的没事。 |
我也遇到这个问题, python3 报 TypeError: Object of type bytes is not JSON serializable |
已经搞定了, 支持最新版的 elastalert0.21, 支持elasticsearch7.x |
我也遇到一样的问题了,小白完全不知道该怎么解决。。。 |
@station19 没有解决。你的代码我试了,一样的问题。一毛一样。 |
@yezhiyuan 程序运行报错: ERROR:root:Uncaught exception running rule frequency_rule: Object of type bytes is not JSON serializable 最后一条信息: INFO:elastalert:Ignoring match for silenced rule frequency_rule 请问楼主解决没?版主有方法?我现在是python3.8环境 |
No description provided.
The text was updated successfully, but these errors were encountered: