[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 ...
随机推荐
- 从connect到express02-中间件morgan
控制台输出请求日志 输出格式 默认格式: dev, combined, tiny等 自定义格式: morgan(':method :url :status :res[content-length] - ...
- [转载] Spring3.1 Cache注解
需要感慨一下,spring3.0时丢弃了2.5时的spring-modules-cache.jar,致使无法使用spring来方便的管理cache注解,好在3.1.M1中增加了对cache注解的支持, ...
- JS的数组相关知识
创建数组方法一: var a1=new Array(5); console.log(a1.length); console.log(a1); //[] ,数组是空的 var a2=new Array( ...
- NAT和SNAT
在Kubernetes负载均衡的方案中遇到了SNAT的问题,查资料把SNAT和NAT的大意了解一下 详细信息可以直接访问 https://support.f5.com/kb/en-us/product ...
- TensorFlow------TFRecords的分析与存储实例
TensorFlow------TFRecords的分析与存储实例: import os import tensorflow as tf # 定义cifar的数据等命令行参数 FLAGS = tf.a ...
- CF(D. Fibonacci Sums)dp计数
题目链接:http://codeforces.com/contest/126/problem/D 题意:一个数能够有多种由互不同样的斐波那契数组成的情况: 解法:dp,easy证明:每一个数通过贪心能 ...
- HDU-2665-Kth number(划分树)
Problem Description Give you a sequence and ask you the kth big number of a inteval. Input The fir ...
- projecteuler---->problem=10----Summation of primes
title: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below tw ...
- Windows下如何替换鼠标指针
鼠标指针替换(应用)教程美化 讲解如何替换鼠标指针,从网上下载的鼠标指针该怎么替换呢?认真看完下边的就会了!鼠标指针常见的文件格式为:.cur..ani两种格式.还可能有的是.exe 格式如果是exe ...
- Adobe Acrobat Pro 11安装激活
运行keygen.exe,点击"generate"一次,生成一个序列号(在安装过程中需要填写序列号). 断网,打开软件,直到出现以下界面,点击蓝色字体"连接Interne ...