本次要完成以下任务:

  • 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邮箱告警的更多相关文章

  1. 【ELK】elastalert 日志告警

    一.环境 系统:centos7 elk 版本:7.6.2 1.1 ElastAlert 工作原理 周期性的查询Elastsearch并且将数据传递给规则类型,规则类型定义了需要查询哪些数据. 当一个规 ...

  2. Nagios 邮箱告警的方式太OUT了!

    一般来讲,在安装完 Nagios 后,我们做的第一件最正确的事,就是设置它的邮件通知,对吧.因为如果没有这一步骤的话,你怎么能够知道什么时候会出现问题呢? 伴随着成功的初始安装,你即将是你司唯一一个能 ...

  3. Zabbix三种邮箱告警配置

    环境 环境 IP地址 主机名 需要安装的应用 系统版本 服务端 192.168.23.140 zabbix lamp zabbix_server zabbix_agent CentOS 8 客户端 1 ...

  4. Zabbix邮箱告警

    一.安装邮箱 yum install mailx 二.配置邮箱 vim /etc/mail.rc set from=875667601@qq.com set smtp=smtp.qq.com set ...

  5. zabbix使用邮箱告警

    目的:使用自己的邮箱(目前我使用的是腾讯企业邮箱)发送告警邮件 1.配置Email:管理->报警媒介类型->Email->修改对应Email参数 2.修改admin用户的报警媒介Em ...

  6. ELK的sentinl告警配置详解

    背景 sentinl的监控&告警是通过watch实现的. 一.Watch Execution 执行开始的时候, watcher为watch创建watch执行上下文. 执行上下文提供脚本和模板, ...

  7. 基于日志报警插件 elastalert 实现告警

    1.官方http://elastalert.readthedocs.io/en/latest/ 2.报警规则示例 http://elastalert.readthedocs.io/en/latest/ ...

  8. Smokeping外置邮箱告警

    wget http://xrl.us/cpanm -O /usr/bin/cpanm 1.安装Authen::SASL模块 cpanm --mirror http://mirrors.163.com/ ...

  9. 基于ELK进行邮箱访问日志的分析

    公司希望能够搭建自己的日志分析系统.现在基于ELK的技术分析日志的公司越来越多,在此也记录一下我利用ELK搭建的日志分析系统. 系统搭建 系统主要是基于elasticsearch+logstash+f ...

随机推荐

  1. cmd复制粘贴

    右击菜单栏,选择“快速编辑模式” 复制:选择文本后按回车,然后就可以去其他地方粘贴了 粘贴:右击鼠标就可以粘贴内容 简单到都不好意思发布出来了....

  2. Unity3D 避免玩家作弊

    如果你的Unity项目快上线了,我强烈建议你看一下Anti-Cheat这个插件.因为IOS和Android分别越狱和Root后玩家可以使用 @八门神器 @烧饼修改器 等一些列作弊的软件来修改游戏内存, ...

  3. [Linux] Linux smaps接口文件结构

    在Linux内核 2.6.16中引入了一个系统内存接口特性,这个接口位于/proc/$pid/目录下的smaps文件中 ,一看内容发现是进程内存映像信息,比同一目录下的maps文件更详细些. 400d ...

  4. Android应用程序访问linux驱动第一步:实现并测试Linux驱动

    一直都想亲自做一次使用android应用程序访问Linux内核驱动的尝试,但总是没能做到.最近抽出时间,下决心重新尝试一次.尝试的开始当然是先写一个Linux内核驱动了. 我希望写一个简单测驱动程序, ...

  5. jQuery最佳实践:如何用好jQuery

    一.用对选择器 在jQuery中,你可以用多种选择器,选择同一个网页元素.每种选择器的性能是不一样的,你应该了解它们的性能差异. (1)最快的选择器:id选择器和元素标签选择器 举例来说,下面的语句性 ...

  6. linux(虚拟机中)与windows共享文件两种方法

      Windows 下用 SourceInsight 与 Linux 协作编码     习惯了用SourceInsight 读写代码,在Linux下一时没找到类似的工具,vi的操作也不熟,偶尔看看或小 ...

  7. DirectX游戏开发——从一个小游戏開始

    本系列文章由birdlove1987编写,转载请注明出处. 文章链接: http://blog.csdn.net/zhurui_idea/article/details/26364129 写在前面:自 ...

  8. 通过web php 执行shell脚本,获取的结果与直接在命令行下获取的结果不同。

    公司项目中的一项小功能,统计设备的连接数.其中用到shell脚本来获取已连接设备的统计.使用命令 /bin/netstat -an| grep ESTABLISHED | awk '{print $4 ...

  9. Intent传递对象的方法

    //传递对象 Bundle bundle = new Bundle(); intent = new Intent(getApplicationContext(), YourActivity.class ...

  10. tornado ThreadPoolExecutor

    import os import sys import time import tornado.httpserver import tornado.ioloop import tornado.opti ...