简述
Elastalert是Yelp公司用python2写的一个报警框架
安装Elastalert(python2.6或2.7)
下载最新elastalert并安装1
2
3
4git clone https://github.com/Yelp/elastalert.git
sudo python setup.y install
sudo pip install -r requirement.txt
安装完成后,会在/usr/local/bin/ 下生成elastalert命令
1 | //查看生成的elastalert命令 |
设置索引
elastalert-create-index 命令创建elasticsearch 创建索引,默认情况下创建的索引是elastalert_status1
./elastalert-create-index
设置配置文件和规则Rule
1 | cp elastalert/config.yaml.example elastalert/config.yaml |
config.yaml中的内容
1 | # This is the folder that contains the rule yaml files |
创建smtp_auth_file.yaml1
2
3
4#发送邮件的邮箱
user: xxx@163.com
#不是邮箱密码,是设置的POP3密码
password: xxx
创建example_frequency.yaml
1 | # Alert when the rate of events exceeds a threshold |
测试规则
1 | elastalert-test-rule ~/elastalert/example_rules/example_frequency.yaml |
运行
1 | cd ~/elastalert |
Docker 安装elastalert
1 | docker pull bitsensor/elastalert |
运行1
2
3
4
5
6
7docker run -d -p 3030:3030 \
-v `pwd`/config/elastalert.yaml:/opt/elastalert/config.yaml \
-v `pwd`/config/config.json:/opt/elastalert-server/config/config.json \
-v `pwd`/rules:/opt/elastalert/rules \
-v `pwd`/rules_templates:/opt/elastalert/rule_templates \
--net="host" \
--name elastalert bitsensor/elastalert:latest