2. ElastAlert安装部署

githup 安装手册

git clone https://github.com/Yelp/elastalert.git

https://elastalert.readthedocs.io/en/latest/running_elastalert.html

 

环境需求

  • Elasticsearch
  • ISO8601 or Unix timestamped data
  • Python 2.7
  • pip, see requirements.txt

pip 安装

sudo yum -y install epel-release #安装epel扩展源

sudo yum -y install python-pip #安装pip

安装依赖包

pip install --upgrade setuptools

python -m pip install --upgrade pip

yum install python-devel libxslt-devel libffi-devel openssl-devel gcc gcc-c++ kernel-devel

 

pip install -r requirements.txt

pip install "elasticsearch>=6.6.1”

 

修改elastalert/elastalert.py 为支持Elastalert6.6

 

def modify_rule_for_ES5(new_rule): # Get ES version per rule rule_es = elasticsearch_client(new_rule) - if rule_es.info()[‘version‘][‘number‘].startswith(‘5‘): + version = rule_es.info()[‘version‘][‘number‘][0:1] + if int(version) >= 5: new_rule[‘five‘] = True else: new_rule[‘five‘] = False

创建索引

python elastalert/create_index.py --host localhost --port 9200 --index elastalert

 

python elastalert/create_index.py --host l00.76.37.64 --port 9200 --index elastalert

 

启动运行

python -m elastalert.elastalert --verbose

解决方案

Centos/Fedora

sudo yum install python-devel

sudo yum install libevent-devel

easy_install gevent

或者

pip install gevent

把环境更新下

sudo yum install groupinstall 'development tools'

上链接供参考;https://www.cnblogs.com/gerrydeng/p/7159021.html

问题二

解决方案

try pip install boto3

上连接供参考 https://stackoverflow.com/questions/48377297/importerror-no-module-named-botocore-session#

 

elastaler 邮件告警配置

#在etc 下创建程序工作目录

mkdir -p /etc/elastalert/rules 

#进入工作目录复制刚刚创建好的配置文件

cd /etc/elastalert/ 

cp /opt/elastalert/config.yaml config.yaml

#进入rules 目录复制rule 文件及smtp 认证文件

cp /elastalert/example_rules/my_rule.yaml my_rule.yaml

cp /opt/elastalert/example_rules/smtp_auth_file.yaml smtp_auth_file.yaml

#接下来我们需要修改配置文件中涉及到相应配置文件目录了,

修改 config.yaml 中

rules_folder:/etc/elastalert/rules 

修改my_rules.yaml 中

smtp_auth_file: /etc/elastalert/rules/smtp_auth_file.yaml

#接下来就是创建systemd服务了

cd /etc/systemd/system/

vim elastalertd.service

 

elastaler 进程长期启动方式

[root@es-aleart system]# vim elastalertd.service

[Unit]

Description=elastalertd

After=elasticsearch.service

 

[Service]

Type=simple

User=root

Group=root

Restart=on-failure

WorkingDirectory=/opt/elastalert

ExecStart=/usr/bin/elastalert --config /etc/elastalert/config.yaml --rule --verbose /etc/elastalert/rules/

[Install]

WantedBy=multi-user.target

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值