首页 > 解决方案 > Elastalert 部署失败

问题描述

我已经在 Centos 7.6 上安装了 elastalert,并且在启动 elastalert 时收到以下错误。

[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

我应该如何解决这个问题?

标签: pythonelasticsearch

解决方案


我自己找到了解决办法。

1.在python2.7上问题依旧

2.安装python3.6版本解决问题。

yum install python3 python3-devel python3-urllib3

3.运行 elastalert 命令

python3 -m elastalert.elastalert --config /root/elastalert/config.yaml --verbose --rule /root/elastalert/example_rules/example_frequency.yaml

4.如果您收到模块问题(ModuleNotFoundError: No module named '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"并得到错误

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='elasticsearch.example.com', port=9200): Max retries exceeded with url: / (Caused by NewConnectionError(': 无法建立新连接: [Errno -2] Name或服务未知',))

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, 'circuit_break_exception', '[parent] Data too large, data for [] will be [994793504/948.7mb], 大于 [986061209/940.3mb] 的限制,real用法:[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"并最终收到另一个错误。

错误:root:查找最近未决警报时出错:NotFoundError(404,'index_not_found_exception','没有这样的索引[elastalert_status]',elastalert_status,index_or_alias){'query':{'bool':{'must':{'query_string' : {'询问': '!存在:aggregate_id AND alert_sent:false'}},'filter': {'range': {'alert_time': {'from': '2019-12-04T19:45:09.635478Z', 'to': '2019- 12-06T19:45:09.635529Z'}}}}},'排序':{'alert_time':{'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 &


推荐阅读