elastalert 用import属性来组织,引入配置
对应rule的一些公用规则,可以放到一个或者多个头文件中。主的rule yaml文件引入即可。文件名随意,最好别用yaml后缀,要不会被当做一个rule。另外import在rule文件中只能出现一次。多个头文件的话可以import文件中引入另外一个import。
示例:
主的myrule.yaml:
import: inc_es.inc name: hs_server_ahc_task system error type: frequency # (Required) # Index to search, wildcard supported index: hs_server_ahc_task* # (Required, frequency specific) # Alert when this many documents matching the query occur within a timeframe num_events: 1 # (Required, frequency specific) # num_events must occur within this amount of time to trigger an alert timeframe: hours: 1 #import: inc_time_field.inc filter: - terms: "Level": ["fatal", "error"] alert_subject: "Alert: System {0} occurred {1} times." alert_subject_args: - Level - "num_hits"
被import的 inc_es.inc 文件:
es_host: 10.10.21.77 # (Optional) # Elasticsearch port es_port: 9200 attach_related: true use_kibana4_dashboard: https://nodejsgbl.italkbb.com/kibana/app/kibana#/dashboard/3bde48d0-9880-11e9-b5d5-2df46b09dea6 email_format: html import: inc_mail.inc
这个又引入 mail.inc
alert: - "email" email: - "bin.zhi@net263.com" #- "zhibingoo@163.com" #- "fsha@net263.com" #- "tiezhou.wei@net263.com" smtp_host: smtp.263.net smtp_port: 25 smtp_auth_file: ../smtp_auth_file.yaml email_reply_to: No.reply@net263.com from_addr: ElastAlert@net263.com #cc: bin.zhi@net263.com
运行:
elastalert --config ../config.yaml --rule hs_ahc_task.yaml --verbose --start 2019-06-27T08:45 --end 2019-06-27T09:55
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2013-06-28 core dump gdb调试