[监控报警]elastalert安装使用
安装
yum -y install python3 git python3-devel cd /usr/local/ git clone https://github.com/Yelp/elastalert.git
pip3 install virtualenv
mkdir -p /usr/local/elastalert/venv_py3.6_elastalert-0.2.1
python3 -m venv /usr/local/elastalert/venv_py3.6_elastalert-0.2.1/
cd venv_py3.6_elastalert-0.2.1/bin/
. activate
pip install -r requirements.txt
pip3 install setuptools-rust
python setup.py install
配置
# mkidr rules # vim config.yaml rules_folder: rules run_every: minutes: 1 buffer_time: minutes: 15 es_host: 192.168.0.37 es_port: 9200 writeback_index: elastalert_status writeback_alias: elastalert_alerts alert_time_limit: days: 2 # vim rules/platform.yaml index: "platform" type: "any" filter: - query: query_string: query: "Level: warm" alert: - "telegram" alert_text: "Level:{0}\nErr:{1}\nTag:{2}\nName:{3}\nBody:{4}\nRequesturl:\n{5}\n Requestbody:\n{6}\n" alert_text_args: ["Level","Err", "tag", "Name", "Body", "Requesturl", "Requestbody"] alert_text_type: alert_text_only telegram_bot_token: 1763406128:AAGsoGbSocvmATQrxL3zq4qPbyJ7LelZEKU telegram_room_id: "-512728603"
验证
elastalert-test-rule config.yaml
启动:
elastalert-create-index
python -m elastalert.elastalert --verbose --rule config.yaml >> /dev/null &