hello-linux / elastalert_wechat_plugin Goto Github PK
View Code? Open in Web Editor NEW一个更加人性化,智能化,简单化的elastalert微信报警插件!
Home Page: https://github.com/Hello-Linux/elastalert_wechat_plugin
License: Apache License 2.0
一个更加人性化,智能化,简单化的elastalert微信报警插件!
Home Page: https://github.com/Hello-Linux/elastalert_wechat_plugin
License: Apache License 2.0
[root@iZ94rc264jtZ elastalert]# python2.7 -m elastalert.elastalert --verbose --config config.yaml --rule es_rules/wechart.yaml
/usr/lib/python2.7/site-packages/requests/init.py:80: RequestsDependencyWarning: urllib3 (1.22) or chardet (2.2.1) doesn't match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/elastalert/elastalert/elastalert.py", line 1925, in
sys.exit(main(sys.argv[1:]))
File "/usr/local/elastalert/elastalert/elastalert.py", line 1919, in main
client = ElastAlerter(args)
File "/usr/local/elastalert/elastalert/elastalert.py", line 108, in init
self.conf = load_rules(self.args)
File "elastalert/config.py", line 500, in load_rules
rule = load_configuration(rule_file, conf, args)
File "elastalert/config.py", line 133, in load_configuration
load_modules(rule, args)
File "elastalert/config.py", line 382, in load_modules
rule['alert'] = load_alerts(rule, alert_field=rule['alert'])
File "elastalert/config.py", line 440, in load_alerts
alert_field = [create_alert(a, b) for a, b in alert_field]
File "elastalert/config.py", line 425, in create_alert
alert_class = alerts_mapping.get(alert) or get_module(alert)
File "elastalert/config.py", line 110, in get_module
base_module = import(module_path, globals(), locals(), [module_class])
File "elastalert_modules/wechat_qiye_alert.py", line 24
def init(self, *args):
IndentationError: unexpected indent
py脚本是直接git下载,语法检查也看不什么问题?
raise ConnectionTimeout('TIMEOUT', str(e), e)
elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ConnectTimeout(HTTPConnectionPool(host='192.168.1.223', port=9200): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7fbccc82ec90>, 'Connection to 192.168.1.223 timed out. (connect timeout=60)')))
ERROR:root:Traceback (most recent call last):
File "/opt/elastalert/elastalert/elastalert.py", line 1335, in alert
return self.send_alert(matches, rule, alert_time=alert_time, retried=retried)
File "/opt/elastalert/elastalert/elastalert.py", line 1424, in send_alert
alert.alert(matches)
File "elastalert_modules/wechat_qiye_alert.py", line 39, in alert
body = self.create_alert_body(matches)
File "elastalert/alerts.py", line 253, in create_alert_body
body += unicode(BasicMatchString(self.rule, match))
File "elastalert/alerts.py", line 144, in str
self._add_custom_alert_text()
File "elastalert/alerts.py", line 81, in _add_custom_alert_text
alert_text = alert_text.format(*alert_text_values)
IndexError: tuple index out of range
ERROR:root:Uncaught exception running rule log_error: tuple index out of range
触发条件时间,时区也不对,需要修复,请问取的是系统时间吗
python3 -m elastalert.elastalert --verbose --rule ../elastalert_wechat_plugin/es_rules/wechart2.yaml --config ../elastalert_wechat_plugin/config/config.yaml
1 rules loaded
INFO:elastalert:Starting up
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 59.999454 seconds
INFO:elastalert:Queried rule schedulee from 2020-03-09 16:26 CST to 2020-03-09 16:30 CST: 12 / 12 hits
/usr/local/python3.6/lib/python3.6/site-packages/urllib3-1.25.8-py3.6.egg/urllib3/connectionpool.py:1004: InsecureRequestWarning: Unverified HTTPS request is being made to host 'qyapi.weixin.qq.com'. 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 "/data/elastalert/elastalert/elastalert.py", line 1450, in alert
return self.send_alert(matches, rule, alert_time=alert_time, retried=retried)
File "/data/elastalert/elastalert/elastalert.py", line 1544, in send_alert
alert.alert(matches)
File "/usr/local/python3.6/lib/python3.6/site-packages/elastalert-0.2.1-py3.6.egg/elastalert_modules/wechat_qiye_alert.py", line 57, in alert
self.senddata(body)
File "/usr/local/python3.6/lib/python3.6/site-packages/elastalert-0.2.1-py3.6.egg/elastalert_modules/wechat_qiye_alert.py", line 124, in senddata
response = requests.post(send_url, data=json.dumps(payload, ensure_ascii=False), headers=headers,verify=False)
File "/usr/local/python3.6/lib/python3.6/json/init.py", line 238, in dumps
**kw).encode(obj)
File "/usr/local/python3.6/lib/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/python3.6/lib/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/local/python3.6/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 schedulee: Object of type 'bytes' is not JSON serializable
INFO:elastalert:Rule schedulee disabled
INFO:elastalert:Ignoring match for silenced rule schedulee
INFO:elastalert:Ignoring match for silenced rule schedulee
INFO:elastalert:Ignoring match for silenced rule schedulee
INFO:elastalert:Ignoring match for silenced rule schedulee
INFO:elastalert:Ignoring match for silenced rule schedulee
INFO:elastalert:Ignoring match for silenced rule schedulee
INFO:elastalert:Ignoring match for silenced rule schedulee
INFO:elastalert:Ignoring match for silenced rule schedulee
INFO:elastalert:Ignoring match for silenced rule schedulee
INFO:elastalert:Ignoring match for silenced rule schedulee
INFO:elastalert:Ignoring match for silenced rule schedulee
INFO:elastalert:Ran schedulee from 2020-03-09 16:26 CST to 2020-03-09 16:30 CST: 12 query hits (0 already seen), 12 matches, 0 alerts sent
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.