elastalert的聚集通知

最近需要配置一套elastalert来监控日志,以下情况:

  1. 日志用Logstash每天一个生成一个index存入es。
  2. 日志中存储运行期的各种信息,包括物理位置,名称,运行信息等等。
  3. 要在运行期信息中找到搜索特定信息,并认定为特定异常,举例:"unable to create native thread", 我们认为是OOM了
  4. 现在要用elastalert监控OOM并报警

很简单的一个需求,配置的rule大概如下:

name: OOM Any Out Rule
type: any

index: applog-*

num_events: 1
timeframe:
  minutes: 10

aggregation:
#  "* * * * *" means: run as the "run_every" in config.yaml
  schedule: "* * * * *"
# several columns of my agg summary table, the table has a default column: count
summary_table_fields:
- "service"
- "stack"
- "name"
- "@timestamp"

filter:
- query:
    query_string:
        query: "message: unable to create native thread"

alert:
- "email"

email:
- "[email protected]"

解释一下:

  1. 因为只需要filter中的一个条件来确定OOM异常,故使用type: any
  2. 使用agg,因为如果不这样设置,那么当这样有多个hit时,es-alert是只存储其中一条hit的。
    INFO:elastalert:Ran OOM Any Out Rule from 2018-05-31 14:04 CST to 2018-05-31 14:07 CST: 3 query hits (0 already seen), 3 matches, 1 alerts sent
    当你只需要agg得到的数量时,这当然ok,但是当你需要每一个hit的信息时,就凉凉了。但是es-alert的文档中说的并不清楚,所以可以看到有非常多的issue在问怎么得到每一个hit。
  3. 以上rule运行时,收到的邮件将包括一个包含"summary_table_fields"中配置的column的表格,并在表格下方遍历所有对应的match_body。
  4. 其实这样的表格读起来并不舒服,因为:
    • 表格没有编号列,不知道自己看到哪一条了
    • 表格默认的count列没有去掉,难受
    • 下方的match_body遍历没有任何标识,看起来复杂,占篇幅又没意义
    • 研究一下怎么解决以上问题

你可能感兴趣的:(elastalert的聚集通知)