自定义 Elastalert 插件收到的警报中的信息

2023-11-25

我已经使用我的 elasticsearch 主机配置了 elastalert 实例。 我还创建了一个示例规则,该规则将在日志中匹配该模式时检查日志级别和警报。

一切工作正常,我在我的松弛通道上正确收到警报。

唯一关心的是我收到的警报中的信息/数据。 elastalert 插件正在发送与我正在寻找的模式相关的所有属性;但我对所有信息都不感兴趣。我所关心的只是一些特定的属性。

这是我的规则的一个例子:

# Alert when the rate of events exceeds a threshold

# (Optional)
# Elasticsearch host
 es_host: 

# (Optional)
# Elasticsearch port
 es_port: 

# (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: DB2 test 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: logstash-* # logstash-2016.04.05 #logstash-YYYY.MM.DD # logstash-*

# (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: 12

# (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:
 - query:
    query_string:
      query: "type: db2 AND logLevel: Warning"

# (Required)
# The alert is use when a match is found
 alert:
 - "slack"
 slack:
 slack_webhook_url: "XYZ"

我在 Slack 频道上收到的警报如下所示:

DB2 test Rule
DB2 test Rule

At least 1 events occurred between 2016-04-29 07:51 UTC and 2016-04-29 19:51 UTC

@timestamp: 2016-04-29T19:51:45.940Z
@version: 1
_id: 
_index: logstash-2016.04.29
_type: db2
apphdl: 
appid: 
authid: 
day: 29
db: NEO
eduid: 
eduname: 
function: 
host: 
hostname: 
hour: 14
id: 
instance: 
logLevel: Warning
logMessage: 
LOADID: 
DATA #2 : 
Completed 
message:       LEVEL: Warning

还有等等等等...

我想自定义此警报消息,以便它仅用我关心的那些属性来提醒我。(对于前时间线、日志级别等。)

有没有办法做到这一点?非常感谢您的一点帮助或追求的方向。


根据ElastAlert 文档,您可以使用以下命令将警报限制为仅包含文档中的某些字段include.

在你的情况下,它将是:

include: ["@timestamp", "logLevel", "message"]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

自定义 Elastalert 插件收到的警报中的信息 的相关文章

随机推荐