我已经在CentOS7.6上安装了弹性警报,并在启动弹性警报时收到以下错误。
[root@e2e-27-36 elastalert]# python -m elastalert.elastalert --verbose --rule example_rules/example_frequency.yaml
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 "/root/elastalert/elastalert/elastalert.py", line 29, in <module>
from . import kibana
File "elastalert/kibana.py", line 4, in <module>
import urllib.error
ImportError: No module named error我该怎么解决这个问题?
发布于 2019-12-06 21:28:48
我自己找到了解决办法。
1.关于python2.7这个问题仍然存在
2.安装python3.6版本以解决此问题。
yum install python3 python3-devel python3-urllib3
3.运行弹性警报命令。
python3 -m elastalert.elastalert --config /root/elastalert/config.yaml --verbose --rule /root/elastalert/example_rules/example_frequency.yaml
4.如果您收到模块的问题(ModuleNotFoundError:没有名为“pytz”的模块)
5.按照要求安装模块。
pip3 install -r /root/elastalert/requirements.txt
6.让我们运行命令"python3 -m elastalert.elastalert --config /root/elastalert/config.yaml --verbose --rule /root/elastalert/example_rules/example_frequency.yaml"并获得错误
HTTPConnectionPool(host='elasticsearch.example.com',port=9200):最大重试超过url: /(由NewConnectionError(':未能建立新连接: Errno -2名称或服务未知“)引起)
7.以上错误是由于config.yaml文件上的主机名无效造成的。编辑config.yaml文件并在es.hosts字段将主机名更改为服务器主机名
确保在/etc/hosts文件中有相同的条目。
8.好的,问题解决了,运行了命令"python3 -m elastalert.elastalert --config /root/elastalert/config.yaml --verbose --rule /root/elastalert/example_rules/example_frequency.yaml",还有一个错误
pkg_resources.DistributionNotFound:“jira>=2.0.0”
9.我们需要使用以下命令安装jira
pip3 install jira==2.0.0
10.现在让我们运行命令"python3 -m elastalert.elastalert --config /root/elastalert/config.yaml --verbose --rule /root/elastalert/example_rules/example_frequency.yaml",并再次运行另一个错误OMG。
elasticsearch.exceptions.TransportError: TransportError(429,“电路中断_异常”,“父数据太大,[]的数据将为994793504/948.7mb,大于986061209/940.3mb,实际使用量: 994793056/948.7mb,保留的新字节: 448/448b')
11.您需要通过更改以下/etc/elasticsearch/jvm.options上的堆值来修复相同的问题。
Xms-1g to Xms-2g Xmx-1g to Xms-2g和重新启动elasticsearch服务"service elasticsearch restart"
12.所有设置都再次运行命令"python3 -m elastalert.elastalert --config /root/elastalert/config.yaml --verbose --rule /root/elastalert/example_rules/example_frequency.yaml",并最终收到另一个错误。
错误:根:错误查找最近挂起的警报: NotFoundError(404,‘index _not_found_Error’,‘无这样的索引弹性警报_状态’,elastalert_status,index_or_alias) {‘查询’:{'bool':{‘必须’:{‘查询_字符串’:{‘查询’:'!exists:aggregate_id和alert_sent:false'}},“筛选器”:{“范围”:{‘警报_时间’:{‘from’from '2019-12-04T19:45:09.635478Z','to':‘2019-12-06T19:45:09.635529Z’}},‘排序’:{‘警报_时间’:{'order':‘asc’}}
13.通过运行以下命令解决问题
elastalert-create-index
14.最后完成所有操作并运行以下命令
python3 -m elastalert.elastalert --config /root/elastalert/config.yaml --verbose --rule /root/elastalert/example_rules/example_frequency.yaml
现在取消命令并在后台运行相同的命令。
python3 -m elastalert.elastalert --config /root/elastalert/config.yaml --verbose --rule /root/elastalert/example_rules/example_frequency.yaml &
发布于 2019-11-25 10:09:47
您可以尝试通过运行urllib3来检查是否安装了pip freeze,也可以尝试使用pip install urllib3重新安装它。
您可能需要正确地激活环境变量,如:source [env]/bin/activate。
发布于 2019-12-03 08:57:58
设置conda环境
conda create -n elastalert python=3.6 anaconda激活conda env
conda activate elastalert安装所有要求
pip install -r requirements-dev.txt
pip install -r requirements.txthttps://stackoverflow.com/questions/59014095
复制相似问题