首页 > 其他分享 >ELK告警设置-Elastaler2

ELK告警设置-Elastaler2

时间:2023-04-28 14:24:42浏览次数:37  
标签:opt ELK message elastalert Elastaler2 alert 告警 elastalert2 es

一、环境说明

机器:172.26.8.146
系统:Centos7.9
ELK:7.6版本

 

二、部署安装

2.1  镜像下载
文档:https://elastalert2.readthedocs.io/en/latest/index.html

docker pull jertel/elastalert2

 

2.2 配置文件配置

可参考 https://github.com/jertel/elastalert2       目录中的examples/config.yaml.example

mkdir -p /opt/elastalert2/{data,rules}

vim /opt/elastalert2/elastalert.yaml

es_host: 172.26.8.146
es_port: 9210
rules_folder: rules
run_every:
  minutes: 5
buffer_time:
  minutes: 10
#es_username: elastic 
#es_password: password
writeback_index: elastalert_status
alert_time_limit:
  days: 2

 

 2.3 启动

# elastalert2
docker run -d  --name elastalert2 \
--restart=always --cpus=2 -m 1g \
-e TZ=Asia/Shanghai \
-v /opt/elastalert2/data:/opt/elastalert/data \
-v /opt/elastalert2/elastalert.yaml:/opt/elastalert/config.yaml \
-v /opt/elastalert2/rules:/opt/elastalert/rules \
jertel/elastalert2

启动完后会自动创建告警索引

 三、Rule规则配置

提前准备好一个发告警的邮箱。
当message日志文件出现 Out of memory,table full,oom 时,通过邮件方式发送给 "[email protected]"。
创建规则,在配置文件中,有一个参数是rules_folder,该参数指定了规则文件存放的位置,根据配置文件,需要把规则文件放到该目录下,在rules目录下,新创建一个system_message.yaml文件,并写入如下内容:

es_host: 172.26.8.146
es_port: 9210
#es_username: elastic
#es_password: password


name: 服务器messages日志告警
use_strftine_index: true
type: frequency

#监控索引
index: prod_messages* 

# 此参数特定于频率类型,是触发警报时的阈值
num_events: 1

#(组合在一起的意思是:在10分钟内有一次触发报警的事件就会触发报警)
timeframe:
  #hours: 1
  minutes: 10

#  词组要在\"  \"里面,否则只要匹配到其中一个单词则触发报警

filter:
- query_string: 
    query: "message: failed OR 
            message: \"Out of memory\" \"table full\" \"oom\"
           " 

alert:
    - "email"

email:
    - "[email protected]"
#邮箱设置    
smtp_host: smtp.126.com
smtp_port: 465
smtp_ssl: true
smtp_auth_file: /opt/elastalert/data/email_auth.yaml
from_addr: [email protected]

## 自定邮件格式
alert_subject: "{0} message告警"
#
alert_subject_args:
  - host

alert_text_type: alert_text_only
#
alert_text: " 
  主机ip: {} \n
  message: {} \n
  发生时间UTC: {} \n
  id: {} \n
  index: {} \n
  num_hits: {} \n
  num_matches: {}
"
alert_text_args:
    - host
    - message
    - "@timestamp"
    - _id
    - _index
    - num_hits
    - num_matches


smtp_auth_file:该参数指定了邮箱登录的认证文件
vim /opt/elastalert/data/email_auth.yaml
user: "[email protected]"
passowrd: "password"


 四、测试效果

 echo "`date +%b" "%d" "%T` oom" >> /var/log/message
 静等几分钟,查看[email protected] 是否收到告警邮件

 

标签:opt,ELK,message,elastalert,Elastaler2,alert,告警,elastalert2,es
From: https://www.cnblogs.com/editlife/p/17361568.html

相关文章

  • zabbix告警配置
    一、配置告警媒介管理->告警媒介类型 二、配置告警动作配置->动作  3、新增用户新增用户,配置告警媒介和服务器权限  ......
  • AI边缘计算智能分析网关灭火器缺失检测与告警的实现过程
    AI智能分析网关基于边缘智能,部署了多种AI深度学习算法,可对接入的多路视频流进行智能检测、智能识别等,包括人脸检测与识别、车辆检测与识别、车牌识别、烟火识别、安全帽识别、区域入侵检测等。今天我们来介绍下关于灭火器缺失检测与告警的实现过程。灭火器缺失检测具体是指,可对......
  • AI边缘计算智能分析网关灭火器缺失检测与告警的实现过程
    AI智能分析网关基于边缘智能,部署了多种AI深度学习算法,可对接入的多路视频流进行智能检测、智能识别等,包括人脸检测与识别、车辆检测与识别、车牌识别、烟火识别、安全帽识别、区域入侵检测等。今天我们来介绍下关于灭火器缺失检测与告警的实现过程。灭火器缺失检测具体是指,可对指定......
  • 容器云平台监控告警体系(五)—— Prometheus发送告警机制
    1、概述在Prometheus的架构中告警被划分为两个部分,在PrometheusServer中定义告警规则以及产生告警,Alertmanager组件则用于处理这些由Prometheus产生的告警。本文主要讲解Prometheus发送告警机制也就是在PrometheusServer中定义告警规则和产生告警部分,不过多介绍Alertmanager组......
  • 即时消息告警工具(二)飞书
    飞书告警登陆飞书移动端后,点击"添加账号"现在登陆的是管理员账号,账号只有审批权限,没有创建应用的权限我们要切换成能创建应用的账号的权限登陆飞书Web端1.https://open.feishu.cn/app飞书后台,可以创建应用,但是需要管理员审批2.https://va8ocx82fwg.feishu.cn/admin/appC......
  • 八、实战案例之基于ELK实现容器日志收集与展示
    kubernetes实战案例之基于ELK实现容器日志收集与展示实现pod中日志收集之至ELK,自定义字段数据格式转换、排序、基于日志实现pod自愈、自动扩容等收集日志的方法:1、通过DaemonSet在宿主机启动日志收集客户端Fluentd、logstash、filebeat-v选项把宿主机的日志挂......
  • ELK日志分析系统
    拓扑图:推荐步骤:搭建ElaticSearch群集,通过浏览器查看和图形管理群集配置客户端装apache和logstash服务配置采集apache日志配置kibana监听elasticsearch服务器日志实验步骤:一、搭建Elaticsearch群集,通过浏览器查看和图形管理群集1、配置第一台Elaticsearch服务器(1)修改hosts文件复制......
  • LInux单机部署ELK日志收集
    LInux单机部署ELK日志收集一、环境准备centos7cpu:1核内存:8G#安装vim,wget,net-tools设置主机名:vim/etc/hosts127.0.0.1localhostlocalhost.localdomainlocalhost4localhost4.localdomain4::1localhostlocalhost.localdomainlocalhost6localhost6.local......
  • elk学习笔记-elasticsearh-head插件以及elasticsearch-dump
     测试使用的elasitcsearch版本是6.3nodejs版本10.9linux版本为centos7.9elasicsearh-head插件Head插件是Elasticsearch的图形化界面工具,通过此插件可以很方便的对数据进行增删改查等数据交互操作。在Elasticsearch5.x版本以后,head插件已经是一个独立的WebApp了,所以不需要和Elasti......
  • 将天擎日志(unicode)推送到wazuh,识别关键字段,触发告警
    背景:使用wazuh对接安全系统日志,根据定义的敏感日志规则,触发告警,并在wazuhdashboard上展示wazuh版本:4.4天擎版本:v6 步骤:1.开启天擎syslog功能##在测试过程中,感觉天擎支持TCP、UDP两种协议,可以抓包看下是哪种协议。##我在设置514端口时,是TCP协议;513端口时,是UDP协议。 ......