[elk]elastalert邮箱告警
本次要完成以下任务:
- 1.源码包安装elasticalert
- 2.配置邮箱报警
原则: 先很快的通过alert报警发一份邮件,其次了解alert配置文件各个选项
源码安装elasticalert
参考:
http://elastalert.readthedocs.io/en/latest/running_elastalert.html
http://www.voidcn.com/article/p-mmtjbhjp-mm.html
https://github.com/Yelp/elastalert
已适合elasticsearch5.x
git clone https://github.com/Yelp/elastalert.git; cd elastalert
yum install gcc libffi-devel python-devel openssl-devel -y
pip install cryptography
pip install "setuptools>=11.3" ## 这里默认你已yum install python-pip并将源指向了aliyun.
python setup.py install
配置邮箱验证
- 配置邮箱用户名密码
$ cat /usr/local/elastalert/example_rules/email_auth.yaml
user: maotai@sina.com
password: 123456
- 修改配置alert配置文件
$ cat example_rules/rule.yaml
es_host: 192.168.x.x
es_port: 9200
name: For A TEST
use_strftine_index: true
type: frequency
index: filebeat-*
num_events: 1
timeframe:
hours: 1
#filter:
# - query:
# query_string:
# query: "@message: *nioEventLoopGroup*"
filter:
- query_string:
query: "message: 测试一下下"
alert:
- "email"
email:
- "maotai@qq.com"
- "maotai2@qq.com"
smtp_host: smtp.sina.com
smtp_port: 25
smtp_ssl: false
smtp_auth_file: /usr/local/elastalert/example_rules/email_auth.yaml
from_addr: maotai@sina.com
启动elasticalert测试
python -m elastalert.elastalert --verbose --rule example_rules/rule.yaml #启动后会自动创建一个elastalert_status的索引.
elk测试环境搭建
- 安装filebeat
- 安装es
- 配置filebeat
- 启动es,filebeat,elasticalert
参考:https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-overview.html
filebeat监控文件,并且向文件里写入内容
确保es能收到.在kibana里观察索引搜到的内容.
$ cat filebeat.yml
filebeat.prospectors:
- type: log
enabled: true
paths:
- /tmp/a.txt
output.elasticsearch:
hosts: ["http://192.168.x.x:9200"]
setup.dashboards.enabled: true
template.enabled: true
template.path: "filebeat.template.json"
template.overwrite: true
output.console:
pretty: true
dashboards.enabled: true
$ cat /tmp/a.txt
测试一下下
测试一下下
测试一下下
测试一下下
查看kibana
查看邮箱-已收到
alert还有kibana插件,以及elasticalert还可以容器方式启动
参考:
https://github.com/bitsensor/elastalert-kibana-plugin
插件下载慢:
https://git.bitsensor.io/front-end/elastalert-kibana-plugin/-/jobs/10874/artifacts/raw/artifact/elastalert-5.6.4-latest.zip
然后
./bin/kibana-plugin install file:///usr/local/src/elastalert-5.6.4-latest.zip
安装后效果:
微信报警:https://github.com/anjia0532/elastalert-wechat-plugin
钉钉报警:https://github.com/xuyaoqiang/elastalert-dingtalk-plugin
告警规则
告警模板
告警时间
告警方式
参考:https://xizhibei.github.io/2017/11/19/alerting-with-elastalert/
https://github.com/chenryn/ELKstack-guide-cn/blob/master/elasticsearch/other/elastalert.md
[elk]elastalert邮箱告警的更多相关文章
- 【ELK】elastalert 日志告警
一.环境 系统:centos7 elk 版本:7.6.2 1.1 ElastAlert 工作原理 周期性的查询Elastsearch并且将数据传递给规则类型,规则类型定义了需要查询哪些数据. 当一个规 ...
- Nagios 邮箱告警的方式太OUT了!
一般来讲,在安装完 Nagios 后,我们做的第一件最正确的事,就是设置它的邮件通知,对吧.因为如果没有这一步骤的话,你怎么能够知道什么时候会出现问题呢? 伴随着成功的初始安装,你即将是你司唯一一个能 ...
- Zabbix三种邮箱告警配置
环境 环境 IP地址 主机名 需要安装的应用 系统版本 服务端 192.168.23.140 zabbix lamp zabbix_server zabbix_agent CentOS 8 客户端 1 ...
- Zabbix邮箱告警
一.安装邮箱 yum install mailx 二.配置邮箱 vim /etc/mail.rc set from=875667601@qq.com set smtp=smtp.qq.com set ...
- zabbix使用邮箱告警
目的:使用自己的邮箱(目前我使用的是腾讯企业邮箱)发送告警邮件 1.配置Email:管理->报警媒介类型->Email->修改对应Email参数 2.修改admin用户的报警媒介Em ...
- ELK的sentinl告警配置详解
背景 sentinl的监控&告警是通过watch实现的. 一.Watch Execution 执行开始的时候, watcher为watch创建watch执行上下文. 执行上下文提供脚本和模板, ...
- 基于日志报警插件 elastalert 实现告警
1.官方http://elastalert.readthedocs.io/en/latest/ 2.报警规则示例 http://elastalert.readthedocs.io/en/latest/ ...
- Smokeping外置邮箱告警
wget http://xrl.us/cpanm -O /usr/bin/cpanm 1.安装Authen::SASL模块 cpanm --mirror http://mirrors.163.com/ ...
- 基于ELK进行邮箱访问日志的分析
公司希望能够搭建自己的日志分析系统.现在基于ELK的技术分析日志的公司越来越多,在此也记录一下我利用ELK搭建的日志分析系统. 系统搭建 系统主要是基于elasticsearch+logstash+f ...
随机推荐
- [HTML/CSS]div显示在object、embed之上~
引言 帮一个朋友弄前端布局,一切都正常,但是嵌入object之后,div总是在object的下面,就上网找了一下解决方案,这里记录一下,好像只对flash有效. 用embed插入一个flash(比如优 ...
- mq组件介绍
作者:Jaskey Lam链接:https://zhuanlan.zhihu.com/p/25069846来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. RocketM ...
- JDK文件夹结构及文件解释
bin:一些命令行工具,包括Java编译器的启动命令. lib:开发工具使用的文件,一些类库 jre:java程序运行环境所需文件
- pca主成份分析方法
1.应用pca的前提 应用pca的前提是,连续信号具有相关性.相关性是什么,是冗余.就是要利用pca去除冗余. 2.pca的定义 pca是一种去除随机变量间相关性的线性变换.是一种常用的多元数据分析方 ...
- windows2012 IIS部署GeoTrust证书踩过的坑。
系统:windows2012 环境:IIS8 在阿里云上买了GeoTrust证书, 按照说明下载证书到服务器, 导入证书, 给IIS站点部署https. 阿里云部署帮助文档:https://help ...
- java POI实现Excel单元格数据换行
当我们通过POI设置了表格的列宽的时候,如果文字过长,希望文字能够自己折行显示. 截取代码如下: Workbook wb = new XSSFWorkbook(); //or new HSSFWork ...
- iOS:文本视图控件UITextView的详细使用
文本视图控件:UITextView 介绍:它是一个文本域的编辑视图,可以在该区域上进行编辑(包括删除.剪贴.复制.修改等),它与文本框UITextField的不同之处是:当它里面的每一行内容超出时,可 ...
- SQL通过身份证获取信息
SELECT t.identity_number '身份证号',SUBSTR(t.identity_number,1,2) AS "省份",SUBSTR(t.identity_nu ...
- [Functional Programming Moand] Update The State Of A State Monad (put)
Stateful computations require the ability for their state to change overtime. We take a look on one ...
- silverlight客户端保存文件乱码问题
最近做一个项目,有一个需求是这样的:服务端从数据库里获得数据,客户端保存为Excel文件 最初解决方案:服务端获得数据,通过ExcelPackage,Convert.ToBase64String将by ...