首页 文章 精选 留言 我的

精选列表

搜索[撒谎模式],共10000篇文章
优秀的个人博客,低调大师

【Elastalert】告警模式之spike配置详解实例

打开微信扫一扫,关注微信公众号【数据与算法联盟】 转载请注明出处: http://blog.csdn.net/gamer_gyt 博主微博: http://weibo.com/234654758 Github: https://github.com/thinkgamer 写在前边的话 Elastalert是由python2.6写的一个告警框架,针对ELK日志分析系统来讲具有很大的作用,在 Elastalert-基于Elasticsearch层面的监控告警框架中,我们了解了Elastalert框架和配置使用了frequence的告警规则,这篇文章我们来看下Spike告警规则,相对来讲,spike rule不是很好理解,希望读者们能够细心阅读,有什么不懂的问题,可以留言讨论 该文永久地址:http://blog.csdn.net/Gamer_gyt/article/details/53381279 环境说明 ubuntu:16.04 Elastalert :0.14 Elasticsearch 2.4.1 Logstash 2.4.0 Kibana 4.6.1 其中的发邮件配置部分参考: Elastalert-基于Elasticsearch层面的监控告警框架 配置文件解读 # 可选的,elasticsearch 所在主机的ip地址 # es_host: elasticsearch.example.com # 可选的,elasticsearch的服务端口 # 这里的elasticsearch之所以说是可选是因为在config.ymal中已经配置过了 # es_port: 14900 # 可选,是否使用SSL加密传送数据,这是因为elasticsearch如果被search-guard或者x-pack/shield保护的话,要启用 #use_ssl: True # 可选,对应访问elasticsearch的账号和密码 #es_username: someusername #es_password: somepassword # 必选的,rule的唯一名字 name: Event spike # 必选的,rule的类型 type: spike # 必选的,监控的索引 index: logstash-* # 二选一,cur:当前窗口,ref:参照窗口 后边会着重讲述 threshold_cur: 5 #threshold_ref: 5 # 必选的,窗口参照时间 timeframe: hours: 2 # 必选的,衡论是否进行报警的一个警戒线 spike_height: 3 # 必选的,spike_type有三种类型,up,down,both spike_type: "up" # 必须的,进行匹配过滤的条件 # 更多过滤条件设置参考: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html filter: - query: query_string: query: "field: value" - type: value: "some_doc_type" # 必须的,报警方式 alert: - "email" # 必选的,邮件的接受地址 email: - "elastalert@example.com" 重要参数解释 spike_type: up:意味着只会匹配超过当事件发生的次数超过spike_height down:意味着只会匹配超过当事件发生的次数低于spike_height both:都会进行匹配 spike_height:最后一个时间帧中的事件数与上一个命中时触发警报的时间帧的比率 threshold_ref:要触发的警报在参考窗口中必须存在的事件的最小数量。例如,如果spike_height:3和threshold_ref:10,则“引用”窗口必须包含至少10个事件,“当前”窗口至少为触发警报的三倍。 threshold_cur:当前窗口中必须存在的触发警报的最小事件数。例如,如果spike_height:3和threshold_cur:60,则当前窗口具有多于60个事件并且参考窗口少于三分之一时,将发生警报。 (当前窗口和参照窗口,而这个窗口就是一个时间段(timeframe)) spike的报警规则 1、如果设置了threshold_ref或者threshold_cur,那么比较对应的ref或cur是否大于threshold_ref或者threshold_cur,如果大于,接着看2,否则不警报; 2、是否满足公式 ref * spike_height < cur ,如果是则警报,否则不警报。 例如: spike_type:up 12:00-14:00发生事件的次数为5,14:00-16:00发生事件的次数为20 设置threshold_cur:6,spike_height:3 由于4<6所以不进行报警 如果我们设置的threshold_cur:4 由于5>4,那么我们看是否满足公式 ref * spike_height < cur ,5*3 > 6不报警 但是如果我们设置的spike_height:1,那么5*1<6,就会进行报警 (这里不是太好理解,大家多读几遍) 实例 前提是ELK和Elastalert都配置OK logstash的配置文件rsyslog_test.conf input { tcp{ port => 5000 type => syslog } udp{ port => 5000 type => syslog } } output { stdout { codec=> rubydebug } elasticsearch { hosts => ["127.0.0.1:9200"] } } elastalert 的example_spike.ymal es_host: 127.0.0.1 es_port: 9200 name: spike rule type: spike index: logstash-* threshold_ref: 3 timeframe: minutes: 1 spike_height: 1 spike_type: "up" filter: - query: query_string: query: "host: 127.0.0.1" - term: _type: "syslog" use_count_query: true doc_type: syslog #SMTP协议的邮件服务器相关配置(我这里是163 mial) smtp_host: smtp.163.com smtp_port: 25 #用户认证文件,需要user和password两个属性 smtp_auth_file: smtp_auth_file.yaml email_reply_to: thinkgamer@163.com from_addr: thinkgamer@163.com alert: - "email" email: - "1923361654@qq.com" 邮件配置部分参考: Elastalert-基于Elasticsearch层面的监控告警框架 系统的/etc/rsyslog.conf,最后加入 *.* @@localhost:5000 *.* @localhost:5000 启动elasticsearch和logstash的rsyslog_test.conf 启动elastalert的example_spike.ymal python -m elastalert.elastalert –verbose –rule example_rules/example_spike.yaml 适当的控制系统的登录日志,最终spike窗口显示如下: master@ubuntu:/opt/elk/elastalert$ python -m elastalert.elastalert --verbose --rule rules/spike.yaml INFO:elastalert:Starting up INFO:elastalert:Queried rule spike rule from 2016-11-28 01:26 PST to 2016-11-28 01:27 PST: 0 hits INFO:elastalert:Ran spike rule from 2016-11-28 01:26 PST to 2016-11-28 01:27 PST: 0 query hits, 0 matches, 0 alerts sent INFO:elastalert:Sleeping for 59 seconds INFO:elastalert:Queried rule spike rule from 2016-11-28 01:27 PST to 2016-11-28 01:28 PST: 22 hits INFO:elastalert:Ran spike rule from 2016-11-28 01:27 PST to 2016-11-28 01:28 PST: 22 query hits, 0 matches, 0 alerts sent INFO:elastalert:Sleeping for 59 seconds INFO:elastalert:Queried rule spike rule from 2016-11-28 01:28 PST to 2016-11-28 01:29 PST: 98 hits INFO:elastalert:Ran spike rule from 2016-11-28 01:28 PST to 2016-11-28 01:29 PST: 98 query hits, 0 matches, 0 alerts sent INFO:elastalert:Sleeping for 59 seconds INFO:elastalert:Queried rule spike rule from 2016-11-28 01:29 PST to 2016-11-28 01:30 PST: 110 hits INFO:elastalert:Sent email to ['1923361654@qq.com'] INFO:elastalert:Ran spike rule from 2016-11-28 01:29 PST to 2016-11-28 01:30 PST: 110 query hits, 1 matches, 1 alerts sent INFO:elastalert:Sleeping for 59 seconds 这个时候邮箱收到邮件内容: OVER !

优秀的个人博客,低调大师

在Ubuntu上安装Hadoop(单机模式)步骤

1. 安装jdk:sudo apt-get install openjdk-6-jdk 2. 配置ssh:安装ssh:apt-get install openssh-server 为运行hadoop的用户生成一个SSH key:$ ssh-keygen -t rsa -P "" 让你可以通过新生成的key来登录本地机器:$ cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys 3. 安装hadoop:下载hadoop tar.gz包并解压:tar -zxvf hadoop-2.2.0.tar.gz 4. 配置:- 在~/.bashrc文件中添加:export HADOOP_HOME=/usr/local/hadoopexport JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64export PATH=$PATH:$HADOOP_HOME/bin在修改完成后保存,重新登录,相应的环境变量就配置好了。 - 配置hadoop-env.sh:export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64 - 配置hdfs-site.xml:<property> <name>hadoop.tmp.dir</name> <value>/app/hadoop/tmp</value> <description>A base for other temporary directories.</description> </property> <property> <name>fs.default.name</name> <value>hdfs://localhost:9000</value> <description>The name of the default file system. A URI whose scheme and authority determine the FileSystem implementation. The uri's scheme determines the config property (fs.SCHEME.impl) naming the FileSystem implementation class. The uri's authority is used to determine the host, port, etc. for a filesystem.</description></property> - 配置mapred-site.xml:<property> <name>mapred.job.tracker</name> <value>localhost:9001</value> <description>The host and port that the MapReduce job tracker runs at. If "local", then jobs are run in-process as a single map and reduce task. </description></property> - 配置hdfs-site.xml:<property> <name>dfs.replication</name> <value>1</value> <description>Default block replication. The actual number of replications can be specified when the file is created. The default is used if replication is not specified in create time. </description> </property> 5. 通过 NameNode 来格式化 HDFS 文件系统$ /usr/local/hadoop/bin/hadoop namenode -format 6. 运行hadoop$ /usr/local/hadoop/sbin/start-all.sh 7. 检查hadoop的运行状况- 使用jps来检查hadoop的运行状况:$ jps - 使用netstat 命令来检查 hadoop 是否正常运行:$ sudo netstat -plten | grep java 8. 停止运行hadoop:$ /usr/local/hadoop/bins/stop-all.sh

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册