安装elast alert的并不像安装文档写的那么easy,虽然如此下面这个博客还是可以推荐下:
http://blog.csdn.net/gamer_gyt/article/details/52917116
官网:http://elastalert.readthedocs.io/en/latest/elastalert.html#overview
1)解压安装:
解压后有一个config.yaml.example文件,将这个文件另存一份并命名为config.yaml。
配置该文件:
# This is the folder that contains the rule yaml files # Any .yaml file will be loaded as a rule rules_folder: example_rules # How often ElastAlert will query Elasticsearch # The unit can be anything from weeks to seconds run_every: minutes: 1 # ElastAlert will buffer results from the most recent # period of time, in case some log sources are not in real time buffer_time: minutes: 3 # The Elasticsearch hostname for metadata writeback # Note that every rule can have its own Elasticsearch host es_host: localhost # The Elasticsearch port es_port: 9200 # The AWS region to use. Set this when using AWS-managed elasticsearch #aws_region: us-east-1 # The AWS profile to use. Use this if you are using an aws-cli profile. # See http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html # for details #profile: test # Optional URL prefix for Elasticsearch #es_url_prefix: elasticsearch # Connect with TLS to Elasticsearch #use_ssl: True # Verify TLS certificates #verify_certs: True # GET request with body is the default option for Elasticsearch. # If it fails for some reason, you can pass 'GET', 'POST' or 'source'. # See http://elasticsearch-py.readthedocs.io/en/master/connection.html?highlight=send_get_body_as#transport # for details #es_send_get_body_as: GET # Option basic-auth username and password for Elasticsearch #es_username: someusername #es_password: somepassword # The index on es_host which is used for metadata storage # This can be a unmapped index, but it is recommended that you run # elastalert-create-index to set a mapping writeback_index: elastalert_status # If an alert fails for some reason, ElastAlert will retry # sending the alert until this time period has elapsed alert_time_limit: days: 2
在elasticsearch中创建索引:
elastalert-create-index
创建Rule:
在example_rules下面,修改example_frequency.yaml文件:
# Alert when the rate of events exceeds a threshold # (Optional) # Elasticsearch host # es_host: elasticsearch.example.com # (Optional) # Elasticsearch port # es_port: 14900 # (OptionaL) Connect with SSL to Elasticsearch #use_ssl: True # (Optional) basic-auth username and password for Elasticsearch #es_username: someusername #es_password: somepassword # (Required) # Rule name, must be unique name: Example frequency rule # (Required) # Type of alert. # the frequency rule type alerts when num_events events occur with timeframe time type: frequency # (Required) # Index to search, wildcard supported index: cloud_platform-* # (Required, frequency specific) # Alert when this many documents matching the query occur within a timeframe num_events: 3 # (Required, frequency specific) # num_events must occur within this amount of time to trigger an alert timeframe: hours: 1 # (Required) # A list of Elasticsearch filters used for find events # These filters are joined with AND and nested in a filtered query # For more info: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html filter: - term: _type: cloud_platform # (Required) # The alert is use when a match is found alert: - "email" # (required, email specific) # a list of email addresses to send alerts to email: - zhuoyp001@xxxx.com email_from_field: zhuoyp001 email_add_domain: "@xxxx.com" from_addr: zhuoyp001@xxxx.com smtp_host: xxxx smtp_port: 25 smtp_auth_file: smtp_auth_file.yaml
这里主要配置了alert的方式是email。
最后一行指定用户名密码的文件smtp_auth_file.yaml:
user: "zhuoyp001@xxxx.com" password: "xxxx"
这样最简单的一个配置就完成了,当type: cloud_platform出现次数为3次后,就发告警邮件给zhuoyp001@xxxx.com。
2)启动:
python -m elastalert.elastalert --verbose --rule example_rules/example_frequency.yaml
正常情况下就启动了,我往logstash里面灌了几条日志,注意时间,eslast alert只去查询当前时间前2分钟内的索引,自己灌入的日志要改时间,让@timestamp满足查询的时间范围。
INFO:elastalert:Ran Example frequency rule from 2017-08-09 08:48 CST to 2017-08-09 08:50 CST: 7 query hits (0 already seen), 2 matches, 1 alerts sent INFO:elastalert:Sleeping for 57.479314 seconds
问题&经验:
alert_time 索引不存在
之前启动的时候,一直报错,说需要排序的字段alert_time不存在。报错在elastalert/elastalert.py文件中。推测原因是因为之前我一直没有触发sent alert这个事件,因此alert_time没有写入索引。于是我把下面几行都注释掉了:
line 1386:sort = {'sort': {'alert_time': {'order': 'asc'}}} line 1391:query.update(sort) line1503:query['sort'] = {'alert_time': {'order': 'desc'}} line1639:sort = {'sort': {'until': {'order': 'desc'}}} line1644:query.update(sort)
再次启动就没有报错了。
最后我触发了发邮件功能后,再次将这些注释掉的行打开,也没有报错可以正常运行。
相关推荐
内容概要:本文详细介绍了LabVIEW控件的设计与实现,尤其是一些由经验丰富的老工程师精心打造的控件。LabVIEW是一款图形化编程语言,广泛应用于数据采集、仪器控制和工业自动化领域。文中通过具体实例展示了如何利用LabVIEW创建美观且功能强大的控件,如滑动条、波形图、金属质感旋钮、动态波形图表以及智能选项卡等。作者强调了LabVIEW控件在灵活性和美观度方面的优势,并分享了许多实用的技术细节和优化方法。 适合人群:具有一定编程基础并希望深入了解LabVIEW控件设计的开发者和技术爱好者。 使用场景及目标:适用于需要进行高效的数据展示和交互设计的应用场景,如工业控制系统、实验室设备操作界面等。目标是帮助用户掌握LabVIEW控件的高级特性,提高开发效率和用户体验。 其他说明:文章不仅提供了具体的代码示例,还探讨了控件美学背后的设计理念和技术实现,鼓励读者探索更多可能性。
Delphi 12.3控件之unidac_10.4.0_d27pro.exe
11.盛趣自闭面(还是自己太菜).txt
58面经面试过程和题目.txt
电大操作系统课后习题解答
人工智能技术与应用演讲【61页PPT】
chromedriver-mac-arm64-135.0.7049.41.zip
内容概要:本文详细介绍了QPSK(四相移键控)调制方法及其在瑞利信道和高斯白噪声信道下的误码率(BER)性能分析。首先展示了QPSK星座图的绘制方法,接着构建了一个简化的QPSK发射机模型,用于将二进制比特流映射到相应的星座点。随后,分别实现了两种信道模型:高斯白噪声信道(AWGN)和瑞利信道,并解释了它们的工作原理以及如何向传输信号添加噪声。文中还提供了详细的误码率测试脚本,通过大量随机比特进行仿真,最终得到了不同信噪比条件下的误码率曲线。此外,作者还讨论了QPSK与其他调制方式如BPSK、16QAM之间的性能差异,强调了频谱效率与抗噪能力之间的权衡关系。 适合人群:对无线通信系统感兴趣的科研人员、研究生以及从事通信工程领域的工程师。 使用场景及目标:①帮助读者理解QPSK的基本原理及其在不同信道环境中的行为特性;②提供实用的Python代码片段,便于快速搭建仿真环境并验证理论结果;③探讨各种调制方式的选择依据,指导实际应用中的优化决策。 其他说明:文中多次提到‘骚操作’,意指一些巧妙但非传统的编程技巧,有助于提高代码执行效率或简化复杂度。同时提醒读者注意仿真过程中可能出现的问题,如
新建 Microsoft Word 文档 (9).docx
计算机科学与技术- 软件开发工具 培训资料
bitcount统计每个元素中设置的位数 B = bitcount(A) Counts the number '1' bits in each element B = bitcount(A, bitValue) "bitValue" = 1 = default = counts the occurance of '1' if bitValue = 0; counts the number '0' The total bits to verify is [8,16,32,or 64] based on the maximal value of A B = bitcount(A, bitValue, maxBits) the total # of bits to examine
MOM生产运营管理平台解决方案【35页PPT】
deli-数码录音电话机-HCD6238(28)P-TSD-使用说明书
Java项目基于ssm框架的课程设计,包含LW+ppt
Delphi 12.3控件之Tsilang 7.5.0.0 D12.7z
ios+UIButton分类+UIButton+UIButton图片文字位置
项目已获导师指导并通过的高分毕业设计项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行!可以放心下载
Java项目基于ssm框架的课程设计,包含LW+ppt
Delphi 12.3控件之TextEditorPro64.7z
尝试给OpenHarmony4.0增加可以在动态库中使用的日志模块 文章使用的资源,防止gitee资源丢失